{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import numpy as np\n",
    "import tensorflow as tf\n",
    "import math\n",
    "import sys\n",
    "sys.path.append(\"..\") \n",
    "import d2lzh_tensorflow2 as d2l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 10, x: 0.06046617599999997\n"
     ]
    }
   ],
   "source": [
    "def gd(eta):\n",
    "    x = 10\n",
    "    results = [x]\n",
    "    for i in range(10):\n",
    "        x -= eta * 2 * x  # f(x) = x * x的导数为f'(x) = 2 * x\n",
    "        results.append(x)\n",
    "    print('epoch 10, x:', x)\n",
    "    return results\n",
    "\n",
    "res = gd(0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Created with matplotlib (http://matplotlib.org/) -->\r\n",
       "<svg height=\"184pt\" version=\"1.1\" viewBox=\"0 0 252 184\" width=\"252pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       " <defs>\r\n",
       "  <style type=\"text/css\">\r\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\r\n",
       "  </style>\r\n",
       " </defs>\r\n",
       " <g id=\"figure_1\">\r\n",
       "  <g id=\"patch_1\">\r\n",
       "   <path d=\"M 0 184.15625 \r\n",
       "L 252.965625 184.15625 \r\n",
       "L 252.965625 -0 \r\n",
       "L 0 -0 \r\n",
       "z\r\n",
       "\" style=\"fill:none;\"/>\r\n",
       "  </g>\r\n",
       "  <g id=\"axes_1\">\r\n",
       "   <g id=\"patch_2\">\r\n",
       "    <path d=\"M 46.965625 146.6 \r\n",
       "L 242.265625 146.6 \r\n",
       "L 242.265625 10.7 \r\n",
       "L 46.965625 10.7 \r\n",
       "z\r\n",
       "\" style=\"fill:#ffffff;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"matplotlib.axis_1\">\r\n",
       "    <g id=\"xtick_1\">\r\n",
       "     <g id=\"line2d_1\">\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 0 0 \r\n",
       "L 0 3.5 \r\n",
       "\" id=\"mb60f43aa3f\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n",
       "      </defs>\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"55.842898\" xlink:href=\"#mb60f43aa3f\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_1\">\r\n",
       "      <!-- −10 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 10.59375 35.5 \r\n",
       "L 73.1875 35.5 \r\n",
       "L 73.1875 27.203125 \r\n",
       "L 10.59375 27.203125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-2212\"/>\r\n",
       "       <path d=\"M 12.40625 8.296875 \r\n",
       "L 28.515625 8.296875 \r\n",
       "L 28.515625 63.921875 \r\n",
       "L 10.984375 60.40625 \r\n",
       "L 10.984375 69.390625 \r\n",
       "L 28.421875 72.90625 \r\n",
       "L 38.28125 72.90625 \r\n",
       "L 38.28125 8.296875 \r\n",
       "L 54.390625 8.296875 \r\n",
       "L 54.390625 0 \r\n",
       "L 12.40625 0 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-31\"/>\r\n",
       "       <path d=\"M 31.78125 66.40625 \r\n",
       "Q 24.171875 66.40625 20.328125 58.90625 \r\n",
       "Q 16.5 51.421875 16.5 36.375 \r\n",
       "Q 16.5 21.390625 20.328125 13.890625 \r\n",
       "Q 24.171875 6.390625 31.78125 6.390625 \r\n",
       "Q 39.453125 6.390625 43.28125 13.890625 \r\n",
       "Q 47.125 21.390625 47.125 36.375 \r\n",
       "Q 47.125 51.421875 43.28125 58.90625 \r\n",
       "Q 39.453125 66.40625 31.78125 66.40625 \r\n",
       "z\r\n",
       "M 31.78125 74.21875 \r\n",
       "Q 44.046875 74.21875 50.515625 64.515625 \r\n",
       "Q 56.984375 54.828125 56.984375 36.375 \r\n",
       "Q 56.984375 17.96875 50.515625 8.265625 \r\n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \r\n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \r\n",
       "Q 6.59375 17.96875 6.59375 36.375 \r\n",
       "Q 6.59375 54.828125 13.0625 64.515625 \r\n",
       "Q 19.53125 74.21875 31.78125 74.21875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-30\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(45.290554 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_2\">\r\n",
       "     <g id=\"line2d_2\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"100.229261\" xlink:href=\"#mb60f43aa3f\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_2\">\r\n",
       "      <!-- −5 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 10.796875 72.90625 \r\n",
       "L 49.515625 72.90625 \r\n",
       "L 49.515625 64.59375 \r\n",
       "L 19.828125 64.59375 \r\n",
       "L 19.828125 46.734375 \r\n",
       "Q 21.96875 47.46875 24.109375 47.828125 \r\n",
       "Q 26.265625 48.1875 28.421875 48.1875 \r\n",
       "Q 40.625 48.1875 47.75 41.5 \r\n",
       "Q 54.890625 34.8125 54.890625 23.390625 \r\n",
       "Q 54.890625 11.625 47.5625 5.09375 \r\n",
       "Q 40.234375 -1.421875 26.90625 -1.421875 \r\n",
       "Q 22.3125 -1.421875 17.546875 -0.640625 \r\n",
       "Q 12.796875 0.140625 7.71875 1.703125 \r\n",
       "L 7.71875 11.625 \r\n",
       "Q 12.109375 9.234375 16.796875 8.0625 \r\n",
       "Q 21.484375 6.890625 26.703125 6.890625 \r\n",
       "Q 35.15625 6.890625 40.078125 11.328125 \r\n",
       "Q 45.015625 15.765625 45.015625 23.390625 \r\n",
       "Q 45.015625 31 40.078125 35.4375 \r\n",
       "Q 35.15625 39.890625 26.703125 39.890625 \r\n",
       "Q 22.75 39.890625 18.8125 39.015625 \r\n",
       "Q 14.890625 38.140625 10.796875 36.28125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-35\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(92.858168 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-35\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_3\">\r\n",
       "     <g id=\"line2d_3\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"144.615625\" xlink:href=\"#mb60f43aa3f\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_3\">\r\n",
       "      <!-- 0 -->\r\n",
       "      <g transform=\"translate(141.434375 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_4\">\r\n",
       "     <g id=\"line2d_4\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"189.001989\" xlink:href=\"#mb60f43aa3f\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_4\">\r\n",
       "      <!-- 5 -->\r\n",
       "      <g transform=\"translate(185.820739 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-35\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_5\">\r\n",
       "     <g id=\"line2d_5\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"233.388352\" xlink:href=\"#mb60f43aa3f\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_5\">\r\n",
       "      <!-- 10 -->\r\n",
       "      <g transform=\"translate(227.025852 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"text_6\">\r\n",
       "     <!-- x -->\r\n",
       "     <defs>\r\n",
       "      <path d=\"M 54.890625 54.6875 \r\n",
       "L 35.109375 28.078125 \r\n",
       "L 55.90625 0 \r\n",
       "L 45.3125 0 \r\n",
       "L 29.390625 21.484375 \r\n",
       "L 13.484375 0 \r\n",
       "L 2.875 0 \r\n",
       "L 24.125 28.609375 \r\n",
       "L 4.6875 54.6875 \r\n",
       "L 15.28125 54.6875 \r\n",
       "L 29.78125 35.203125 \r\n",
       "L 44.28125 54.6875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-78\"/>\r\n",
       "     </defs>\r\n",
       "     <g transform=\"translate(141.65625 174.876562)scale(0.1 -0.1)\">\r\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"matplotlib.axis_2\">\r\n",
       "    <g id=\"ytick_1\">\r\n",
       "     <g id=\"line2d_6\">\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 0 0 \r\n",
       "L -3.5 0 \r\n",
       "\" id=\"m84401efeab\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n",
       "      </defs>\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m84401efeab\" y=\"140.422727\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_7\">\r\n",
       "      <!-- 0 -->\r\n",
       "      <g transform=\"translate(33.603125 144.221946)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_2\">\r\n",
       "     <g id=\"line2d_7\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m84401efeab\" y=\"115.713636\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_8\">\r\n",
       "      <!-- 20 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 19.1875 8.296875 \r\n",
       "L 53.609375 8.296875 \r\n",
       "L 53.609375 0 \r\n",
       "L 7.328125 0 \r\n",
       "L 7.328125 8.296875 \r\n",
       "Q 12.9375 14.109375 22.625 23.890625 \r\n",
       "Q 32.328125 33.6875 34.8125 36.53125 \r\n",
       "Q 39.546875 41.84375 41.421875 45.53125 \r\n",
       "Q 43.3125 49.21875 43.3125 52.78125 \r\n",
       "Q 43.3125 58.59375 39.234375 62.25 \r\n",
       "Q 35.15625 65.921875 28.609375 65.921875 \r\n",
       "Q 23.96875 65.921875 18.8125 64.3125 \r\n",
       "Q 13.671875 62.703125 7.8125 59.421875 \r\n",
       "L 7.8125 69.390625 \r\n",
       "Q 13.765625 71.78125 18.9375 73 \r\n",
       "Q 24.125 74.21875 28.421875 74.21875 \r\n",
       "Q 39.75 74.21875 46.484375 68.546875 \r\n",
       "Q 53.21875 62.890625 53.21875 53.421875 \r\n",
       "Q 53.21875 48.921875 51.53125 44.890625 \r\n",
       "Q 49.859375 40.875 45.40625 35.40625 \r\n",
       "Q 44.1875 33.984375 37.640625 27.21875 \r\n",
       "Q 31.109375 20.453125 19.1875 8.296875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-32\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(27.240625 119.512855)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_3\">\r\n",
       "     <g id=\"line2d_8\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m84401efeab\" y=\"91.004545\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_9\">\r\n",
       "      <!-- 40 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 37.796875 64.3125 \r\n",
       "L 12.890625 25.390625 \r\n",
       "L 37.796875 25.390625 \r\n",
       "z\r\n",
       "M 35.203125 72.90625 \r\n",
       "L 47.609375 72.90625 \r\n",
       "L 47.609375 25.390625 \r\n",
       "L 58.015625 25.390625 \r\n",
       "L 58.015625 17.1875 \r\n",
       "L 47.609375 17.1875 \r\n",
       "L 47.609375 0 \r\n",
       "L 37.796875 0 \r\n",
       "L 37.796875 17.1875 \r\n",
       "L 4.890625 17.1875 \r\n",
       "L 4.890625 26.703125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-34\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(27.240625 94.803764)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_4\">\r\n",
       "     <g id=\"line2d_9\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m84401efeab\" y=\"66.295455\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_10\">\r\n",
       "      <!-- 60 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 33.015625 40.375 \r\n",
       "Q 26.375 40.375 22.484375 35.828125 \r\n",
       "Q 18.609375 31.296875 18.609375 23.390625 \r\n",
       "Q 18.609375 15.53125 22.484375 10.953125 \r\n",
       "Q 26.375 6.390625 33.015625 6.390625 \r\n",
       "Q 39.65625 6.390625 43.53125 10.953125 \r\n",
       "Q 47.40625 15.53125 47.40625 23.390625 \r\n",
       "Q 47.40625 31.296875 43.53125 35.828125 \r\n",
       "Q 39.65625 40.375 33.015625 40.375 \r\n",
       "z\r\n",
       "M 52.59375 71.296875 \r\n",
       "L 52.59375 62.3125 \r\n",
       "Q 48.875 64.0625 45.09375 64.984375 \r\n",
       "Q 41.3125 65.921875 37.59375 65.921875 \r\n",
       "Q 27.828125 65.921875 22.671875 59.328125 \r\n",
       "Q 17.53125 52.734375 16.796875 39.40625 \r\n",
       "Q 19.671875 43.65625 24.015625 45.921875 \r\n",
       "Q 28.375 48.1875 33.59375 48.1875 \r\n",
       "Q 44.578125 48.1875 50.953125 41.515625 \r\n",
       "Q 57.328125 34.859375 57.328125 23.390625 \r\n",
       "Q 57.328125 12.15625 50.6875 5.359375 \r\n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \r\n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \r\n",
       "Q 6.984375 17.96875 6.984375 36.375 \r\n",
       "Q 6.984375 53.65625 15.1875 63.9375 \r\n",
       "Q 23.390625 74.21875 37.203125 74.21875 \r\n",
       "Q 40.921875 74.21875 44.703125 73.484375 \r\n",
       "Q 48.484375 72.75 52.59375 71.296875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-36\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(27.240625 70.094673)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_5\">\r\n",
       "     <g id=\"line2d_10\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m84401efeab\" y=\"41.586364\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_11\">\r\n",
       "      <!-- 80 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 31.78125 34.625 \r\n",
       "Q 24.75 34.625 20.71875 30.859375 \r\n",
       "Q 16.703125 27.09375 16.703125 20.515625 \r\n",
       "Q 16.703125 13.921875 20.71875 10.15625 \r\n",
       "Q 24.75 6.390625 31.78125 6.390625 \r\n",
       "Q 38.8125 6.390625 42.859375 10.171875 \r\n",
       "Q 46.921875 13.96875 46.921875 20.515625 \r\n",
       "Q 46.921875 27.09375 42.890625 30.859375 \r\n",
       "Q 38.875 34.625 31.78125 34.625 \r\n",
       "z\r\n",
       "M 21.921875 38.8125 \r\n",
       "Q 15.578125 40.375 12.03125 44.71875 \r\n",
       "Q 8.5 49.078125 8.5 55.328125 \r\n",
       "Q 8.5 64.0625 14.71875 69.140625 \r\n",
       "Q 20.953125 74.21875 31.78125 74.21875 \r\n",
       "Q 42.671875 74.21875 48.875 69.140625 \r\n",
       "Q 55.078125 64.0625 55.078125 55.328125 \r\n",
       "Q 55.078125 49.078125 51.53125 44.71875 \r\n",
       "Q 48 40.375 41.703125 38.8125 \r\n",
       "Q 48.828125 37.15625 52.796875 32.3125 \r\n",
       "Q 56.78125 27.484375 56.78125 20.515625 \r\n",
       "Q 56.78125 9.90625 50.3125 4.234375 \r\n",
       "Q 43.84375 -1.421875 31.78125 -1.421875 \r\n",
       "Q 19.734375 -1.421875 13.25 4.234375 \r\n",
       "Q 6.78125 9.90625 6.78125 20.515625 \r\n",
       "Q 6.78125 27.484375 10.78125 32.3125 \r\n",
       "Q 14.796875 37.15625 21.921875 38.8125 \r\n",
       "z\r\n",
       "M 18.3125 54.390625 \r\n",
       "Q 18.3125 48.734375 21.84375 45.5625 \r\n",
       "Q 25.390625 42.390625 31.78125 42.390625 \r\n",
       "Q 38.140625 42.390625 41.71875 45.5625 \r\n",
       "Q 45.3125 48.734375 45.3125 54.390625 \r\n",
       "Q 45.3125 60.0625 41.71875 63.234375 \r\n",
       "Q 38.140625 66.40625 31.78125 66.40625 \r\n",
       "Q 25.390625 66.40625 21.84375 63.234375 \r\n",
       "Q 18.3125 60.0625 18.3125 54.390625 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-38\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(27.240625 45.385582)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_6\">\r\n",
       "     <g id=\"line2d_11\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m84401efeab\" y=\"16.877273\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_12\">\r\n",
       "      <!-- 100 -->\r\n",
       "      <g transform=\"translate(20.878125 20.676491)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"text_13\">\r\n",
       "     <!-- f(x) -->\r\n",
       "     <defs>\r\n",
       "      <path d=\"M 37.109375 75.984375 \r\n",
       "L 37.109375 68.5 \r\n",
       "L 28.515625 68.5 \r\n",
       "Q 23.6875 68.5 21.796875 66.546875 \r\n",
       "Q 19.921875 64.59375 19.921875 59.515625 \r\n",
       "L 19.921875 54.6875 \r\n",
       "L 34.71875 54.6875 \r\n",
       "L 34.71875 47.703125 \r\n",
       "L 19.921875 47.703125 \r\n",
       "L 19.921875 0 \r\n",
       "L 10.890625 0 \r\n",
       "L 10.890625 47.703125 \r\n",
       "L 2.296875 47.703125 \r\n",
       "L 2.296875 54.6875 \r\n",
       "L 10.890625 54.6875 \r\n",
       "L 10.890625 58.5 \r\n",
       "Q 10.890625 67.625 15.140625 71.796875 \r\n",
       "Q 19.390625 75.984375 28.609375 75.984375 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-66\"/>\r\n",
       "      <path d=\"M 31 75.875 \r\n",
       "Q 24.46875 64.65625 21.28125 53.65625 \r\n",
       "Q 18.109375 42.671875 18.109375 31.390625 \r\n",
       "Q 18.109375 20.125 21.3125 9.0625 \r\n",
       "Q 24.515625 -2 31 -13.1875 \r\n",
       "L 23.1875 -13.1875 \r\n",
       "Q 15.875 -1.703125 12.234375 9.375 \r\n",
       "Q 8.59375 20.453125 8.59375 31.390625 \r\n",
       "Q 8.59375 42.28125 12.203125 53.3125 \r\n",
       "Q 15.828125 64.359375 23.1875 75.875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-28\"/>\r\n",
       "      <path d=\"M 8.015625 75.875 \r\n",
       "L 15.828125 75.875 \r\n",
       "Q 23.140625 64.359375 26.78125 53.3125 \r\n",
       "Q 30.421875 42.28125 30.421875 31.390625 \r\n",
       "Q 30.421875 20.453125 26.78125 9.375 \r\n",
       "Q 23.140625 -1.703125 15.828125 -13.1875 \r\n",
       "L 8.015625 -13.1875 \r\n",
       "Q 14.5 -2 17.703125 9.0625 \r\n",
       "Q 20.90625 20.125 20.90625 31.390625 \r\n",
       "Q 20.90625 42.671875 17.703125 53.65625 \r\n",
       "Q 14.5 64.65625 8.015625 75.875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-29\"/>\r\n",
       "     </defs>\r\n",
       "     <g transform=\"translate(14.798438 87.271094)rotate(-90)scale(0.1 -0.1)\">\r\n",
       "      <use xlink:href=\"#DejaVuSans-66\"/>\r\n",
       "      <use x=\"35.205078\" xlink:href=\"#DejaVuSans-28\"/>\r\n",
       "      <use x=\"74.21875\" xlink:href=\"#DejaVuSans-78\"/>\r\n",
       "      <use x=\"133.398438\" xlink:href=\"#DejaVuSans-29\"/>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"line2d_12\">\r\n",
       "    <path clip-path=\"url(#p8e3742642e)\" d=\"M 55.842898 16.877273 \r\n",
       "L 60.281534 28.922955 \r\n",
       "L 64.72017 40.350909 \r\n",
       "L 69.158807 51.161136 \r\n",
       "L 73.597443 61.353636 \r\n",
       "L 78.03608 70.928409 \r\n",
       "L 82.474716 79.885455 \r\n",
       "L 86.025625 86.606327 \r\n",
       "L 89.576534 92.931855 \r\n",
       "L 93.127443 98.862036 \r\n",
       "L 96.678352 104.396873 \r\n",
       "L 100.229261 109.536364 \r\n",
       "L 103.78017 114.280509 \r\n",
       "L 107.33108 118.629309 \r\n",
       "L 110.881989 122.582764 \r\n",
       "L 114.432898 126.140873 \r\n",
       "L 117.983807 129.303636 \r\n",
       "L 120.646989 131.416264 \r\n",
       "L 123.31017 133.306509 \r\n",
       "L 125.973352 134.974373 \r\n",
       "L 128.636534 136.419855 \r\n",
       "L 131.299716 137.642955 \r\n",
       "L 133.962898 138.643673 \r\n",
       "L 136.62608 139.422009 \r\n",
       "L 139.289261 139.977964 \r\n",
       "L 141.952443 140.311536 \r\n",
       "L 144.615625 140.422727 \r\n",
       "L 147.278807 140.311536 \r\n",
       "L 149.941989 139.977964 \r\n",
       "L 152.60517 139.422009 \r\n",
       "L 155.268352 138.643673 \r\n",
       "L 157.931534 137.642955 \r\n",
       "L 160.594716 136.419855 \r\n",
       "L 163.257898 134.974373 \r\n",
       "L 165.92108 133.306509 \r\n",
       "L 168.584261 131.416264 \r\n",
       "L 171.247443 129.303636 \r\n",
       "L 173.910625 126.968627 \r\n",
       "L 177.461534 123.509355 \r\n",
       "L 181.012443 119.654736 \r\n",
       "L 184.563352 115.404773 \r\n",
       "L 188.114261 110.759464 \r\n",
       "L 191.66517 105.718809 \r\n",
       "L 195.21608 100.282809 \r\n",
       "L 198.766989 94.451464 \r\n",
       "L 202.317898 88.224773 \r\n",
       "L 205.868807 81.602736 \r\n",
       "L 209.419716 74.585355 \r\n",
       "L 213.858352 65.257673 \r\n",
       "L 218.296989 55.312264 \r\n",
       "L 222.735625 44.749127 \r\n",
       "L 227.174261 33.568264 \r\n",
       "L 231.612898 21.769673 \r\n",
       "L 232.500625 19.335827 \r\n",
       "L 232.500625 19.335827 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"line2d_13\">\r\n",
       "    <path clip-path=\"url(#p8e3742642e)\" d=\"M 233.388352 16.877273 \r\n",
       "L 197.879261 95.946364 \r\n",
       "L 176.573807 124.411236 \r\n",
       "L 163.790534 134.658591 \r\n",
       "L 156.12057 138.347638 \r\n",
       "L 151.518592 139.675695 \r\n",
       "L 148.757405 140.153796 \r\n",
       "L 147.100693 140.325912 \r\n",
       "L 146.106666 140.387874 \r\n",
       "L 145.51025 140.41018 \r\n",
       "L 145.1524 140.41821 \r\n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:1.5;\"/>\r\n",
       "    <defs>\r\n",
       "     <path d=\"M 0 3 \r\n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \r\n",
       "C 2.683901 1.55874 3 0.795609 3 0 \r\n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \r\n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \r\n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \r\n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \r\n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \r\n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \r\n",
       "z\r\n",
       "\" id=\"mce064ca196\" style=\"stroke:#ff7f0e;\"/>\r\n",
       "    </defs>\r\n",
       "    <g clip-path=\"url(#p8e3742642e)\">\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"233.388352\" xlink:href=\"#mce064ca196\" y=\"16.877273\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"197.879261\" xlink:href=\"#mce064ca196\" y=\"95.946364\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"176.573807\" xlink:href=\"#mce064ca196\" y=\"124.411236\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"163.790534\" xlink:href=\"#mce064ca196\" y=\"134.658591\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"156.12057\" xlink:href=\"#mce064ca196\" y=\"138.347638\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"151.518592\" xlink:href=\"#mce064ca196\" y=\"139.675695\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"148.757405\" xlink:href=\"#mce064ca196\" y=\"140.153796\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"147.100693\" xlink:href=\"#mce064ca196\" y=\"140.325912\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"146.106666\" xlink:href=\"#mce064ca196\" y=\"140.387874\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"145.51025\" xlink:href=\"#mce064ca196\" y=\"140.41018\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"145.1524\" xlink:href=\"#mce064ca196\" y=\"140.41821\"/>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_3\">\r\n",
       "    <path d=\"M 46.965625 146.6 \r\n",
       "L 46.965625 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_4\">\r\n",
       "    <path d=\"M 242.265625 146.6 \r\n",
       "L 242.265625 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_5\">\r\n",
       "    <path d=\"M 46.965625 146.6 \r\n",
       "L 242.265625 146.6 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_6\">\r\n",
       "    <path d=\"M 46.965625 10.7 \r\n",
       "L 242.265625 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "  </g>\r\n",
       " </g>\r\n",
       " <defs>\r\n",
       "  <clipPath id=\"p8e3742642e\">\r\n",
       "   <rect height=\"135.9\" width=\"195.3\" x=\"46.965625\" y=\"10.7\"/>\r\n",
       "  </clipPath>\r\n",
       " </defs>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x175b916a0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def show_trace(res):\n",
    "    n = max(abs(min(res)), abs(max(res)), 10)\n",
    "    f_line = np.arange(-n, n, 0.1)\n",
    "    d2l.set_figsize()\n",
    "    d2l.plt.plot(f_line, [x * x for x in f_line])\n",
    "    d2l.plt.plot(res, [x * x for x in res], '-o')\n",
    "    d2l.plt.xlabel('x')\n",
    "    d2l.plt.ylabel('f(x)')\n",
    "\n",
    "show_trace(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 10, x: 3.4867844009999995\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Created with matplotlib (http://matplotlib.org/) -->\r\n",
       "<svg height=\"184pt\" version=\"1.1\" viewBox=\"0 0 252 184\" width=\"252pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       " <defs>\r\n",
       "  <style type=\"text/css\">\r\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\r\n",
       "  </style>\r\n",
       " </defs>\r\n",
       " <g id=\"figure_1\">\r\n",
       "  <g id=\"patch_1\">\r\n",
       "   <path d=\"M 0 184.15625 \r\n",
       "L 252.965625 184.15625 \r\n",
       "L 252.965625 -0 \r\n",
       "L 0 -0 \r\n",
       "z\r\n",
       "\" style=\"fill:none;\"/>\r\n",
       "  </g>\r\n",
       "  <g id=\"axes_1\">\r\n",
       "   <g id=\"patch_2\">\r\n",
       "    <path d=\"M 46.965625 146.6 \r\n",
       "L 242.265625 146.6 \r\n",
       "L 242.265625 10.7 \r\n",
       "L 46.965625 10.7 \r\n",
       "z\r\n",
       "\" style=\"fill:#ffffff;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"matplotlib.axis_1\">\r\n",
       "    <g id=\"xtick_1\">\r\n",
       "     <g id=\"line2d_1\">\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 0 0 \r\n",
       "L 0 3.5 \r\n",
       "\" id=\"m8c916b6516\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n",
       "      </defs>\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"55.842898\" xlink:href=\"#m8c916b6516\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_1\">\r\n",
       "      <!-- −10 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 10.59375 35.5 \r\n",
       "L 73.1875 35.5 \r\n",
       "L 73.1875 27.203125 \r\n",
       "L 10.59375 27.203125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-2212\"/>\r\n",
       "       <path d=\"M 12.40625 8.296875 \r\n",
       "L 28.515625 8.296875 \r\n",
       "L 28.515625 63.921875 \r\n",
       "L 10.984375 60.40625 \r\n",
       "L 10.984375 69.390625 \r\n",
       "L 28.421875 72.90625 \r\n",
       "L 38.28125 72.90625 \r\n",
       "L 38.28125 8.296875 \r\n",
       "L 54.390625 8.296875 \r\n",
       "L 54.390625 0 \r\n",
       "L 12.40625 0 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-31\"/>\r\n",
       "       <path d=\"M 31.78125 66.40625 \r\n",
       "Q 24.171875 66.40625 20.328125 58.90625 \r\n",
       "Q 16.5 51.421875 16.5 36.375 \r\n",
       "Q 16.5 21.390625 20.328125 13.890625 \r\n",
       "Q 24.171875 6.390625 31.78125 6.390625 \r\n",
       "Q 39.453125 6.390625 43.28125 13.890625 \r\n",
       "Q 47.125 21.390625 47.125 36.375 \r\n",
       "Q 47.125 51.421875 43.28125 58.90625 \r\n",
       "Q 39.453125 66.40625 31.78125 66.40625 \r\n",
       "z\r\n",
       "M 31.78125 74.21875 \r\n",
       "Q 44.046875 74.21875 50.515625 64.515625 \r\n",
       "Q 56.984375 54.828125 56.984375 36.375 \r\n",
       "Q 56.984375 17.96875 50.515625 8.265625 \r\n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \r\n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \r\n",
       "Q 6.59375 17.96875 6.59375 36.375 \r\n",
       "Q 6.59375 54.828125 13.0625 64.515625 \r\n",
       "Q 19.53125 74.21875 31.78125 74.21875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-30\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(45.290554 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_2\">\r\n",
       "     <g id=\"line2d_2\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"100.229261\" xlink:href=\"#m8c916b6516\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_2\">\r\n",
       "      <!-- −5 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 10.796875 72.90625 \r\n",
       "L 49.515625 72.90625 \r\n",
       "L 49.515625 64.59375 \r\n",
       "L 19.828125 64.59375 \r\n",
       "L 19.828125 46.734375 \r\n",
       "Q 21.96875 47.46875 24.109375 47.828125 \r\n",
       "Q 26.265625 48.1875 28.421875 48.1875 \r\n",
       "Q 40.625 48.1875 47.75 41.5 \r\n",
       "Q 54.890625 34.8125 54.890625 23.390625 \r\n",
       "Q 54.890625 11.625 47.5625 5.09375 \r\n",
       "Q 40.234375 -1.421875 26.90625 -1.421875 \r\n",
       "Q 22.3125 -1.421875 17.546875 -0.640625 \r\n",
       "Q 12.796875 0.140625 7.71875 1.703125 \r\n",
       "L 7.71875 11.625 \r\n",
       "Q 12.109375 9.234375 16.796875 8.0625 \r\n",
       "Q 21.484375 6.890625 26.703125 6.890625 \r\n",
       "Q 35.15625 6.890625 40.078125 11.328125 \r\n",
       "Q 45.015625 15.765625 45.015625 23.390625 \r\n",
       "Q 45.015625 31 40.078125 35.4375 \r\n",
       "Q 35.15625 39.890625 26.703125 39.890625 \r\n",
       "Q 22.75 39.890625 18.8125 39.015625 \r\n",
       "Q 14.890625 38.140625 10.796875 36.28125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-35\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(92.858168 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-35\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_3\">\r\n",
       "     <g id=\"line2d_3\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"144.615625\" xlink:href=\"#m8c916b6516\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_3\">\r\n",
       "      <!-- 0 -->\r\n",
       "      <g transform=\"translate(141.434375 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_4\">\r\n",
       "     <g id=\"line2d_4\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"189.001989\" xlink:href=\"#m8c916b6516\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_4\">\r\n",
       "      <!-- 5 -->\r\n",
       "      <g transform=\"translate(185.820739 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-35\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_5\">\r\n",
       "     <g id=\"line2d_5\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"233.388352\" xlink:href=\"#m8c916b6516\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_5\">\r\n",
       "      <!-- 10 -->\r\n",
       "      <g transform=\"translate(227.025852 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"text_6\">\r\n",
       "     <!-- x -->\r\n",
       "     <defs>\r\n",
       "      <path d=\"M 54.890625 54.6875 \r\n",
       "L 35.109375 28.078125 \r\n",
       "L 55.90625 0 \r\n",
       "L 45.3125 0 \r\n",
       "L 29.390625 21.484375 \r\n",
       "L 13.484375 0 \r\n",
       "L 2.875 0 \r\n",
       "L 24.125 28.609375 \r\n",
       "L 4.6875 54.6875 \r\n",
       "L 15.28125 54.6875 \r\n",
       "L 29.78125 35.203125 \r\n",
       "L 44.28125 54.6875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-78\"/>\r\n",
       "     </defs>\r\n",
       "     <g transform=\"translate(141.65625 174.876562)scale(0.1 -0.1)\">\r\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"matplotlib.axis_2\">\r\n",
       "    <g id=\"ytick_1\">\r\n",
       "     <g id=\"line2d_6\">\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 0 0 \r\n",
       "L -3.5 0 \r\n",
       "\" id=\"m9d66008e08\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n",
       "      </defs>\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m9d66008e08\" y=\"140.422727\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_7\">\r\n",
       "      <!-- 0 -->\r\n",
       "      <g transform=\"translate(33.603125 144.221946)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_2\">\r\n",
       "     <g id=\"line2d_7\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m9d66008e08\" y=\"115.713636\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_8\">\r\n",
       "      <!-- 20 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 19.1875 8.296875 \r\n",
       "L 53.609375 8.296875 \r\n",
       "L 53.609375 0 \r\n",
       "L 7.328125 0 \r\n",
       "L 7.328125 8.296875 \r\n",
       "Q 12.9375 14.109375 22.625 23.890625 \r\n",
       "Q 32.328125 33.6875 34.8125 36.53125 \r\n",
       "Q 39.546875 41.84375 41.421875 45.53125 \r\n",
       "Q 43.3125 49.21875 43.3125 52.78125 \r\n",
       "Q 43.3125 58.59375 39.234375 62.25 \r\n",
       "Q 35.15625 65.921875 28.609375 65.921875 \r\n",
       "Q 23.96875 65.921875 18.8125 64.3125 \r\n",
       "Q 13.671875 62.703125 7.8125 59.421875 \r\n",
       "L 7.8125 69.390625 \r\n",
       "Q 13.765625 71.78125 18.9375 73 \r\n",
       "Q 24.125 74.21875 28.421875 74.21875 \r\n",
       "Q 39.75 74.21875 46.484375 68.546875 \r\n",
       "Q 53.21875 62.890625 53.21875 53.421875 \r\n",
       "Q 53.21875 48.921875 51.53125 44.890625 \r\n",
       "Q 49.859375 40.875 45.40625 35.40625 \r\n",
       "Q 44.1875 33.984375 37.640625 27.21875 \r\n",
       "Q 31.109375 20.453125 19.1875 8.296875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-32\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(27.240625 119.512855)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_3\">\r\n",
       "     <g id=\"line2d_8\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m9d66008e08\" y=\"91.004545\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_9\">\r\n",
       "      <!-- 40 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 37.796875 64.3125 \r\n",
       "L 12.890625 25.390625 \r\n",
       "L 37.796875 25.390625 \r\n",
       "z\r\n",
       "M 35.203125 72.90625 \r\n",
       "L 47.609375 72.90625 \r\n",
       "L 47.609375 25.390625 \r\n",
       "L 58.015625 25.390625 \r\n",
       "L 58.015625 17.1875 \r\n",
       "L 47.609375 17.1875 \r\n",
       "L 47.609375 0 \r\n",
       "L 37.796875 0 \r\n",
       "L 37.796875 17.1875 \r\n",
       "L 4.890625 17.1875 \r\n",
       "L 4.890625 26.703125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-34\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(27.240625 94.803764)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_4\">\r\n",
       "     <g id=\"line2d_9\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m9d66008e08\" y=\"66.295455\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_10\">\r\n",
       "      <!-- 60 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 33.015625 40.375 \r\n",
       "Q 26.375 40.375 22.484375 35.828125 \r\n",
       "Q 18.609375 31.296875 18.609375 23.390625 \r\n",
       "Q 18.609375 15.53125 22.484375 10.953125 \r\n",
       "Q 26.375 6.390625 33.015625 6.390625 \r\n",
       "Q 39.65625 6.390625 43.53125 10.953125 \r\n",
       "Q 47.40625 15.53125 47.40625 23.390625 \r\n",
       "Q 47.40625 31.296875 43.53125 35.828125 \r\n",
       "Q 39.65625 40.375 33.015625 40.375 \r\n",
       "z\r\n",
       "M 52.59375 71.296875 \r\n",
       "L 52.59375 62.3125 \r\n",
       "Q 48.875 64.0625 45.09375 64.984375 \r\n",
       "Q 41.3125 65.921875 37.59375 65.921875 \r\n",
       "Q 27.828125 65.921875 22.671875 59.328125 \r\n",
       "Q 17.53125 52.734375 16.796875 39.40625 \r\n",
       "Q 19.671875 43.65625 24.015625 45.921875 \r\n",
       "Q 28.375 48.1875 33.59375 48.1875 \r\n",
       "Q 44.578125 48.1875 50.953125 41.515625 \r\n",
       "Q 57.328125 34.859375 57.328125 23.390625 \r\n",
       "Q 57.328125 12.15625 50.6875 5.359375 \r\n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \r\n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \r\n",
       "Q 6.984375 17.96875 6.984375 36.375 \r\n",
       "Q 6.984375 53.65625 15.1875 63.9375 \r\n",
       "Q 23.390625 74.21875 37.203125 74.21875 \r\n",
       "Q 40.921875 74.21875 44.703125 73.484375 \r\n",
       "Q 48.484375 72.75 52.59375 71.296875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-36\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(27.240625 70.094673)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_5\">\r\n",
       "     <g id=\"line2d_10\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m9d66008e08\" y=\"41.586364\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_11\">\r\n",
       "      <!-- 80 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 31.78125 34.625 \r\n",
       "Q 24.75 34.625 20.71875 30.859375 \r\n",
       "Q 16.703125 27.09375 16.703125 20.515625 \r\n",
       "Q 16.703125 13.921875 20.71875 10.15625 \r\n",
       "Q 24.75 6.390625 31.78125 6.390625 \r\n",
       "Q 38.8125 6.390625 42.859375 10.171875 \r\n",
       "Q 46.921875 13.96875 46.921875 20.515625 \r\n",
       "Q 46.921875 27.09375 42.890625 30.859375 \r\n",
       "Q 38.875 34.625 31.78125 34.625 \r\n",
       "z\r\n",
       "M 21.921875 38.8125 \r\n",
       "Q 15.578125 40.375 12.03125 44.71875 \r\n",
       "Q 8.5 49.078125 8.5 55.328125 \r\n",
       "Q 8.5 64.0625 14.71875 69.140625 \r\n",
       "Q 20.953125 74.21875 31.78125 74.21875 \r\n",
       "Q 42.671875 74.21875 48.875 69.140625 \r\n",
       "Q 55.078125 64.0625 55.078125 55.328125 \r\n",
       "Q 55.078125 49.078125 51.53125 44.71875 \r\n",
       "Q 48 40.375 41.703125 38.8125 \r\n",
       "Q 48.828125 37.15625 52.796875 32.3125 \r\n",
       "Q 56.78125 27.484375 56.78125 20.515625 \r\n",
       "Q 56.78125 9.90625 50.3125 4.234375 \r\n",
       "Q 43.84375 -1.421875 31.78125 -1.421875 \r\n",
       "Q 19.734375 -1.421875 13.25 4.234375 \r\n",
       "Q 6.78125 9.90625 6.78125 20.515625 \r\n",
       "Q 6.78125 27.484375 10.78125 32.3125 \r\n",
       "Q 14.796875 37.15625 21.921875 38.8125 \r\n",
       "z\r\n",
       "M 18.3125 54.390625 \r\n",
       "Q 18.3125 48.734375 21.84375 45.5625 \r\n",
       "Q 25.390625 42.390625 31.78125 42.390625 \r\n",
       "Q 38.140625 42.390625 41.71875 45.5625 \r\n",
       "Q 45.3125 48.734375 45.3125 54.390625 \r\n",
       "Q 45.3125 60.0625 41.71875 63.234375 \r\n",
       "Q 38.140625 66.40625 31.78125 66.40625 \r\n",
       "Q 25.390625 66.40625 21.84375 63.234375 \r\n",
       "Q 18.3125 60.0625 18.3125 54.390625 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-38\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(27.240625 45.385582)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_6\">\r\n",
       "     <g id=\"line2d_11\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"46.965625\" xlink:href=\"#m9d66008e08\" y=\"16.877273\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_12\">\r\n",
       "      <!-- 100 -->\r\n",
       "      <g transform=\"translate(20.878125 20.676491)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"text_13\">\r\n",
       "     <!-- f(x) -->\r\n",
       "     <defs>\r\n",
       "      <path d=\"M 37.109375 75.984375 \r\n",
       "L 37.109375 68.5 \r\n",
       "L 28.515625 68.5 \r\n",
       "Q 23.6875 68.5 21.796875 66.546875 \r\n",
       "Q 19.921875 64.59375 19.921875 59.515625 \r\n",
       "L 19.921875 54.6875 \r\n",
       "L 34.71875 54.6875 \r\n",
       "L 34.71875 47.703125 \r\n",
       "L 19.921875 47.703125 \r\n",
       "L 19.921875 0 \r\n",
       "L 10.890625 0 \r\n",
       "L 10.890625 47.703125 \r\n",
       "L 2.296875 47.703125 \r\n",
       "L 2.296875 54.6875 \r\n",
       "L 10.890625 54.6875 \r\n",
       "L 10.890625 58.5 \r\n",
       "Q 10.890625 67.625 15.140625 71.796875 \r\n",
       "Q 19.390625 75.984375 28.609375 75.984375 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-66\"/>\r\n",
       "      <path d=\"M 31 75.875 \r\n",
       "Q 24.46875 64.65625 21.28125 53.65625 \r\n",
       "Q 18.109375 42.671875 18.109375 31.390625 \r\n",
       "Q 18.109375 20.125 21.3125 9.0625 \r\n",
       "Q 24.515625 -2 31 -13.1875 \r\n",
       "L 23.1875 -13.1875 \r\n",
       "Q 15.875 -1.703125 12.234375 9.375 \r\n",
       "Q 8.59375 20.453125 8.59375 31.390625 \r\n",
       "Q 8.59375 42.28125 12.203125 53.3125 \r\n",
       "Q 15.828125 64.359375 23.1875 75.875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-28\"/>\r\n",
       "      <path d=\"M 8.015625 75.875 \r\n",
       "L 15.828125 75.875 \r\n",
       "Q 23.140625 64.359375 26.78125 53.3125 \r\n",
       "Q 30.421875 42.28125 30.421875 31.390625 \r\n",
       "Q 30.421875 20.453125 26.78125 9.375 \r\n",
       "Q 23.140625 -1.703125 15.828125 -13.1875 \r\n",
       "L 8.015625 -13.1875 \r\n",
       "Q 14.5 -2 17.703125 9.0625 \r\n",
       "Q 20.90625 20.125 20.90625 31.390625 \r\n",
       "Q 20.90625 42.671875 17.703125 53.65625 \r\n",
       "Q 14.5 64.65625 8.015625 75.875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-29\"/>\r\n",
       "     </defs>\r\n",
       "     <g transform=\"translate(14.798438 87.271094)rotate(-90)scale(0.1 -0.1)\">\r\n",
       "      <use xlink:href=\"#DejaVuSans-66\"/>\r\n",
       "      <use x=\"35.205078\" xlink:href=\"#DejaVuSans-28\"/>\r\n",
       "      <use x=\"74.21875\" xlink:href=\"#DejaVuSans-78\"/>\r\n",
       "      <use x=\"133.398438\" xlink:href=\"#DejaVuSans-29\"/>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"line2d_12\">\r\n",
       "    <path clip-path=\"url(#pd9618efb52)\" d=\"M 55.842898 16.877273 \r\n",
       "L 60.281534 28.922955 \r\n",
       "L 64.72017 40.350909 \r\n",
       "L 69.158807 51.161136 \r\n",
       "L 73.597443 61.353636 \r\n",
       "L 78.03608 70.928409 \r\n",
       "L 82.474716 79.885455 \r\n",
       "L 86.025625 86.606327 \r\n",
       "L 89.576534 92.931855 \r\n",
       "L 93.127443 98.862036 \r\n",
       "L 96.678352 104.396873 \r\n",
       "L 100.229261 109.536364 \r\n",
       "L 103.78017 114.280509 \r\n",
       "L 107.33108 118.629309 \r\n",
       "L 110.881989 122.582764 \r\n",
       "L 114.432898 126.140873 \r\n",
       "L 117.983807 129.303636 \r\n",
       "L 120.646989 131.416264 \r\n",
       "L 123.31017 133.306509 \r\n",
       "L 125.973352 134.974373 \r\n",
       "L 128.636534 136.419855 \r\n",
       "L 131.299716 137.642955 \r\n",
       "L 133.962898 138.643673 \r\n",
       "L 136.62608 139.422009 \r\n",
       "L 139.289261 139.977964 \r\n",
       "L 141.952443 140.311536 \r\n",
       "L 144.615625 140.422727 \r\n",
       "L 147.278807 140.311536 \r\n",
       "L 149.941989 139.977964 \r\n",
       "L 152.60517 139.422009 \r\n",
       "L 155.268352 138.643673 \r\n",
       "L 157.931534 137.642955 \r\n",
       "L 160.594716 136.419855 \r\n",
       "L 163.257898 134.974373 \r\n",
       "L 165.92108 133.306509 \r\n",
       "L 168.584261 131.416264 \r\n",
       "L 171.247443 129.303636 \r\n",
       "L 173.910625 126.968627 \r\n",
       "L 177.461534 123.509355 \r\n",
       "L 181.012443 119.654736 \r\n",
       "L 184.563352 115.404773 \r\n",
       "L 188.114261 110.759464 \r\n",
       "L 191.66517 105.718809 \r\n",
       "L 195.21608 100.282809 \r\n",
       "L 198.766989 94.451464 \r\n",
       "L 202.317898 88.224773 \r\n",
       "L 205.868807 81.602736 \r\n",
       "L 209.419716 74.585355 \r\n",
       "L 213.858352 65.257673 \r\n",
       "L 218.296989 55.312264 \r\n",
       "L 222.735625 44.749127 \r\n",
       "L 227.174261 33.568264 \r\n",
       "L 231.612898 21.769673 \r\n",
       "L 232.500625 19.335827 \r\n",
       "L 232.500625 19.335827 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"line2d_13\">\r\n",
       "    <path clip-path=\"url(#pd9618efb52)\" d=\"M 233.388352 16.877273 \r\n",
       "L 224.51108 40.350909 \r\n",
       "L 216.521534 59.364555 \r\n",
       "L 209.330943 74.765607 \r\n",
       "L 202.859411 87.24046 \r\n",
       "L 197.035033 97.345091 \r\n",
       "L 191.793092 105.529842 \r\n",
       "L 187.075345 112.15949 \r\n",
       "L 182.829373 117.529505 \r\n",
       "L 179.007998 121.879217 \r\n",
       "L 175.568761 125.402484 \r\n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:1.5;\"/>\r\n",
       "    <defs>\r\n",
       "     <path d=\"M 0 3 \r\n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \r\n",
       "C 2.683901 1.55874 3 0.795609 3 0 \r\n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \r\n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \r\n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \r\n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \r\n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \r\n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \r\n",
       "z\r\n",
       "\" id=\"mc34722d4cb\" style=\"stroke:#ff7f0e;\"/>\r\n",
       "    </defs>\r\n",
       "    <g clip-path=\"url(#pd9618efb52)\">\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"233.388352\" xlink:href=\"#mc34722d4cb\" y=\"16.877273\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"224.51108\" xlink:href=\"#mc34722d4cb\" y=\"40.350909\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"216.521534\" xlink:href=\"#mc34722d4cb\" y=\"59.364555\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"209.330943\" xlink:href=\"#mc34722d4cb\" y=\"74.765607\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"202.859411\" xlink:href=\"#mc34722d4cb\" y=\"87.24046\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"197.035033\" xlink:href=\"#mc34722d4cb\" y=\"97.345091\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"191.793092\" xlink:href=\"#mc34722d4cb\" y=\"105.529842\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"187.075345\" xlink:href=\"#mc34722d4cb\" y=\"112.15949\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"182.829373\" xlink:href=\"#mc34722d4cb\" y=\"117.529505\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"179.007998\" xlink:href=\"#mc34722d4cb\" y=\"121.879217\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"175.568761\" xlink:href=\"#mc34722d4cb\" y=\"125.402484\"/>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_3\">\r\n",
       "    <path d=\"M 46.965625 146.6 \r\n",
       "L 46.965625 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_4\">\r\n",
       "    <path d=\"M 242.265625 146.6 \r\n",
       "L 242.265625 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_5\">\r\n",
       "    <path d=\"M 46.965625 146.6 \r\n",
       "L 242.265625 146.6 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_6\">\r\n",
       "    <path d=\"M 46.965625 10.7 \r\n",
       "L 242.265625 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "  </g>\r\n",
       " </g>\r\n",
       " <defs>\r\n",
       "  <clipPath id=\"pd9618efb52\">\r\n",
       "   <rect height=\"135.9\" width=\"195.3\" x=\"46.965625\" y=\"10.7\"/>\r\n",
       "  </clipPath>\r\n",
       " </defs>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x175b87b00>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "show_trace(gd(0.05))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 10, x: 61.917364224000096\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Created with matplotlib (http://matplotlib.org/) -->\r\n",
       "<svg height=\"184pt\" version=\"1.1\" viewBox=\"0 0 259 184\" width=\"259pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       " <defs>\r\n",
       "  <style type=\"text/css\">\r\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\r\n",
       "  </style>\r\n",
       " </defs>\r\n",
       " <g id=\"figure_1\">\r\n",
       "  <g id=\"patch_1\">\r\n",
       "   <path d=\"M 0 184.15625 \r\n",
       "L 259.328125 184.15625 \r\n",
       "L 259.328125 -0 \r\n",
       "L 0 -0 \r\n",
       "z\r\n",
       "\" style=\"fill:none;\"/>\r\n",
       "  </g>\r\n",
       "  <g id=\"axes_1\">\r\n",
       "   <g id=\"patch_2\">\r\n",
       "    <path d=\"M 53.328125 146.6 \r\n",
       "L 248.628125 146.6 \r\n",
       "L 248.628125 10.7 \r\n",
       "L 53.328125 10.7 \r\n",
       "z\r\n",
       "\" style=\"fill:#ffffff;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"matplotlib.axis_1\">\r\n",
       "    <g id=\"xtick_1\">\r\n",
       "     <g id=\"line2d_1\">\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 0 0 \r\n",
       "L 0 3.5 \r\n",
       "\" id=\"mffb62f6a1c\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n",
       "      </defs>\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"79.29167\" xlink:href=\"#mffb62f6a1c\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_1\">\r\n",
       "      <!-- −50 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 10.59375 35.5 \r\n",
       "L 73.1875 35.5 \r\n",
       "L 73.1875 27.203125 \r\n",
       "L 10.59375 27.203125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-2212\"/>\r\n",
       "       <path d=\"M 10.796875 72.90625 \r\n",
       "L 49.515625 72.90625 \r\n",
       "L 49.515625 64.59375 \r\n",
       "L 19.828125 64.59375 \r\n",
       "L 19.828125 46.734375 \r\n",
       "Q 21.96875 47.46875 24.109375 47.828125 \r\n",
       "Q 26.265625 48.1875 28.421875 48.1875 \r\n",
       "Q 40.625 48.1875 47.75 41.5 \r\n",
       "Q 54.890625 34.8125 54.890625 23.390625 \r\n",
       "Q 54.890625 11.625 47.5625 5.09375 \r\n",
       "Q 40.234375 -1.421875 26.90625 -1.421875 \r\n",
       "Q 22.3125 -1.421875 17.546875 -0.640625 \r\n",
       "Q 12.796875 0.140625 7.71875 1.703125 \r\n",
       "L 7.71875 11.625 \r\n",
       "Q 12.109375 9.234375 16.796875 8.0625 \r\n",
       "Q 21.484375 6.890625 26.703125 6.890625 \r\n",
       "Q 35.15625 6.890625 40.078125 11.328125 \r\n",
       "Q 45.015625 15.765625 45.015625 23.390625 \r\n",
       "Q 45.015625 31 40.078125 35.4375 \r\n",
       "Q 35.15625 39.890625 26.703125 39.890625 \r\n",
       "Q 22.75 39.890625 18.8125 39.015625 \r\n",
       "Q 14.890625 38.140625 10.796875 36.28125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-35\"/>\r\n",
       "       <path d=\"M 31.78125 66.40625 \r\n",
       "Q 24.171875 66.40625 20.328125 58.90625 \r\n",
       "Q 16.5 51.421875 16.5 36.375 \r\n",
       "Q 16.5 21.390625 20.328125 13.890625 \r\n",
       "Q 24.171875 6.390625 31.78125 6.390625 \r\n",
       "Q 39.453125 6.390625 43.28125 13.890625 \r\n",
       "Q 47.125 21.390625 47.125 36.375 \r\n",
       "Q 47.125 51.421875 43.28125 58.90625 \r\n",
       "Q 39.453125 66.40625 31.78125 66.40625 \r\n",
       "z\r\n",
       "M 31.78125 74.21875 \r\n",
       "Q 44.046875 74.21875 50.515625 64.515625 \r\n",
       "Q 56.984375 54.828125 56.984375 36.375 \r\n",
       "Q 56.984375 17.96875 50.515625 8.265625 \r\n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \r\n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \r\n",
       "Q 6.59375 17.96875 6.59375 36.375 \r\n",
       "Q 6.59375 54.828125 13.0625 64.515625 \r\n",
       "Q 19.53125 74.21875 31.78125 74.21875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-30\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(68.739326 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-35\"/>\r\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_2\">\r\n",
       "     <g id=\"line2d_2\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"115.134897\" xlink:href=\"#mffb62f6a1c\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_2\">\r\n",
       "      <!-- −25 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 19.1875 8.296875 \r\n",
       "L 53.609375 8.296875 \r\n",
       "L 53.609375 0 \r\n",
       "L 7.328125 0 \r\n",
       "L 7.328125 8.296875 \r\n",
       "Q 12.9375 14.109375 22.625 23.890625 \r\n",
       "Q 32.328125 33.6875 34.8125 36.53125 \r\n",
       "Q 39.546875 41.84375 41.421875 45.53125 \r\n",
       "Q 43.3125 49.21875 43.3125 52.78125 \r\n",
       "Q 43.3125 58.59375 39.234375 62.25 \r\n",
       "Q 35.15625 65.921875 28.609375 65.921875 \r\n",
       "Q 23.96875 65.921875 18.8125 64.3125 \r\n",
       "Q 13.671875 62.703125 7.8125 59.421875 \r\n",
       "L 7.8125 69.390625 \r\n",
       "Q 13.765625 71.78125 18.9375 73 \r\n",
       "Q 24.125 74.21875 28.421875 74.21875 \r\n",
       "Q 39.75 74.21875 46.484375 68.546875 \r\n",
       "Q 53.21875 62.890625 53.21875 53.421875 \r\n",
       "Q 53.21875 48.921875 51.53125 44.890625 \r\n",
       "Q 49.859375 40.875 45.40625 35.40625 \r\n",
       "Q 44.1875 33.984375 37.640625 27.21875 \r\n",
       "Q 31.109375 20.453125 19.1875 8.296875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-32\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(104.582554 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSans-35\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_3\">\r\n",
       "     <g id=\"line2d_3\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"150.978125\" xlink:href=\"#mffb62f6a1c\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_3\">\r\n",
       "      <!-- 0 -->\r\n",
       "      <g transform=\"translate(147.796875 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_4\">\r\n",
       "     <g id=\"line2d_4\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"186.821353\" xlink:href=\"#mffb62f6a1c\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_4\">\r\n",
       "      <!-- 25 -->\r\n",
       "      <g transform=\"translate(180.458853 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-35\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_5\">\r\n",
       "     <g id=\"line2d_5\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"222.66458\" xlink:href=\"#mffb62f6a1c\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_5\">\r\n",
       "      <!-- 50 -->\r\n",
       "      <g transform=\"translate(216.30208 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-35\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"text_6\">\r\n",
       "     <!-- x -->\r\n",
       "     <defs>\r\n",
       "      <path d=\"M 54.890625 54.6875 \r\n",
       "L 35.109375 28.078125 \r\n",
       "L 55.90625 0 \r\n",
       "L 45.3125 0 \r\n",
       "L 29.390625 21.484375 \r\n",
       "L 13.484375 0 \r\n",
       "L 2.875 0 \r\n",
       "L 24.125 28.609375 \r\n",
       "L 4.6875 54.6875 \r\n",
       "L 15.28125 54.6875 \r\n",
       "L 29.78125 35.203125 \r\n",
       "L 44.28125 54.6875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-78\"/>\r\n",
       "     </defs>\r\n",
       "     <g transform=\"translate(148.01875 174.876562)scale(0.1 -0.1)\">\r\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"matplotlib.axis_2\">\r\n",
       "    <g id=\"ytick_1\">\r\n",
       "     <g id=\"line2d_6\">\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 0 0 \r\n",
       "L -3.5 0 \r\n",
       "\" id=\"me08deeb262\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n",
       "      </defs>\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"53.328125\" xlink:href=\"#me08deeb262\" y=\"140.422737\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_7\">\r\n",
       "      <!-- 0 -->\r\n",
       "      <g transform=\"translate(39.965625 144.221956)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_2\">\r\n",
       "     <g id=\"line2d_7\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"53.328125\" xlink:href=\"#me08deeb262\" y=\"108.197072\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_8\">\r\n",
       "      <!-- 1000 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 12.40625 8.296875 \r\n",
       "L 28.515625 8.296875 \r\n",
       "L 28.515625 63.921875 \r\n",
       "L 10.984375 60.40625 \r\n",
       "L 10.984375 69.390625 \r\n",
       "L 28.421875 72.90625 \r\n",
       "L 38.28125 72.90625 \r\n",
       "L 38.28125 8.296875 \r\n",
       "L 54.390625 8.296875 \r\n",
       "L 54.390625 0 \r\n",
       "L 12.40625 0 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-31\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(20.878125 111.996291)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_3\">\r\n",
       "     <g id=\"line2d_8\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"53.328125\" xlink:href=\"#me08deeb262\" y=\"75.971407\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_9\">\r\n",
       "      <!-- 2000 -->\r\n",
       "      <g transform=\"translate(20.878125 79.770626)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_4\">\r\n",
       "     <g id=\"line2d_9\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"53.328125\" xlink:href=\"#me08deeb262\" y=\"43.745743\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_10\">\r\n",
       "      <!-- 3000 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 40.578125 39.3125 \r\n",
       "Q 47.65625 37.796875 51.625 33 \r\n",
       "Q 55.609375 28.21875 55.609375 21.1875 \r\n",
       "Q 55.609375 10.40625 48.1875 4.484375 \r\n",
       "Q 40.765625 -1.421875 27.09375 -1.421875 \r\n",
       "Q 22.515625 -1.421875 17.65625 -0.515625 \r\n",
       "Q 12.796875 0.390625 7.625 2.203125 \r\n",
       "L 7.625 11.71875 \r\n",
       "Q 11.71875 9.328125 16.59375 8.109375 \r\n",
       "Q 21.484375 6.890625 26.8125 6.890625 \r\n",
       "Q 36.078125 6.890625 40.9375 10.546875 \r\n",
       "Q 45.796875 14.203125 45.796875 21.1875 \r\n",
       "Q 45.796875 27.640625 41.28125 31.265625 \r\n",
       "Q 36.765625 34.90625 28.71875 34.90625 \r\n",
       "L 20.21875 34.90625 \r\n",
       "L 20.21875 43.015625 \r\n",
       "L 29.109375 43.015625 \r\n",
       "Q 36.375 43.015625 40.234375 45.921875 \r\n",
       "Q 44.09375 48.828125 44.09375 54.296875 \r\n",
       "Q 44.09375 59.90625 40.109375 62.90625 \r\n",
       "Q 36.140625 65.921875 28.71875 65.921875 \r\n",
       "Q 24.65625 65.921875 20.015625 65.03125 \r\n",
       "Q 15.375 64.15625 9.8125 62.3125 \r\n",
       "L 9.8125 71.09375 \r\n",
       "Q 15.4375 72.65625 20.34375 73.4375 \r\n",
       "Q 25.25 74.21875 29.59375 74.21875 \r\n",
       "Q 40.828125 74.21875 47.359375 69.109375 \r\n",
       "Q 53.90625 64.015625 53.90625 55.328125 \r\n",
       "Q 53.90625 49.265625 50.4375 45.09375 \r\n",
       "Q 46.96875 40.921875 40.578125 39.3125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-33\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(20.878125 47.544961)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-33\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_5\">\r\n",
       "     <g id=\"line2d_10\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"53.328125\" xlink:href=\"#me08deeb262\" y=\"11.520078\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_11\">\r\n",
       "      <!-- 4000 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 37.796875 64.3125 \r\n",
       "L 12.890625 25.390625 \r\n",
       "L 37.796875 25.390625 \r\n",
       "z\r\n",
       "M 35.203125 72.90625 \r\n",
       "L 47.609375 72.90625 \r\n",
       "L 47.609375 25.390625 \r\n",
       "L 58.015625 25.390625 \r\n",
       "L 58.015625 17.1875 \r\n",
       "L 47.609375 17.1875 \r\n",
       "L 47.609375 0 \r\n",
       "L 37.796875 0 \r\n",
       "L 37.796875 17.1875 \r\n",
       "L 4.890625 17.1875 \r\n",
       "L 4.890625 26.703125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-34\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(20.878125 15.319297)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\r\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"text_12\">\r\n",
       "     <!-- f(x) -->\r\n",
       "     <defs>\r\n",
       "      <path d=\"M 37.109375 75.984375 \r\n",
       "L 37.109375 68.5 \r\n",
       "L 28.515625 68.5 \r\n",
       "Q 23.6875 68.5 21.796875 66.546875 \r\n",
       "Q 19.921875 64.59375 19.921875 59.515625 \r\n",
       "L 19.921875 54.6875 \r\n",
       "L 34.71875 54.6875 \r\n",
       "L 34.71875 47.703125 \r\n",
       "L 19.921875 47.703125 \r\n",
       "L 19.921875 0 \r\n",
       "L 10.890625 0 \r\n",
       "L 10.890625 47.703125 \r\n",
       "L 2.296875 47.703125 \r\n",
       "L 2.296875 54.6875 \r\n",
       "L 10.890625 54.6875 \r\n",
       "L 10.890625 58.5 \r\n",
       "Q 10.890625 67.625 15.140625 71.796875 \r\n",
       "Q 19.390625 75.984375 28.609375 75.984375 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-66\"/>\r\n",
       "      <path d=\"M 31 75.875 \r\n",
       "Q 24.46875 64.65625 21.28125 53.65625 \r\n",
       "Q 18.109375 42.671875 18.109375 31.390625 \r\n",
       "Q 18.109375 20.125 21.3125 9.0625 \r\n",
       "Q 24.515625 -2 31 -13.1875 \r\n",
       "L 23.1875 -13.1875 \r\n",
       "Q 15.875 -1.703125 12.234375 9.375 \r\n",
       "Q 8.59375 20.453125 8.59375 31.390625 \r\n",
       "Q 8.59375 42.28125 12.203125 53.3125 \r\n",
       "Q 15.828125 64.359375 23.1875 75.875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-28\"/>\r\n",
       "      <path d=\"M 8.015625 75.875 \r\n",
       "L 15.828125 75.875 \r\n",
       "Q 23.140625 64.359375 26.78125 53.3125 \r\n",
       "Q 30.421875 42.28125 30.421875 31.390625 \r\n",
       "Q 30.421875 20.453125 26.78125 9.375 \r\n",
       "Q 23.140625 -1.703125 15.828125 -13.1875 \r\n",
       "L 8.015625 -13.1875 \r\n",
       "Q 14.5 -2 17.703125 9.0625 \r\n",
       "Q 20.90625 20.125 20.90625 31.390625 \r\n",
       "Q 20.90625 42.671875 17.703125 53.65625 \r\n",
       "Q 14.5 64.65625 8.015625 75.875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-29\"/>\r\n",
       "     </defs>\r\n",
       "     <g transform=\"translate(14.798437 87.271094)rotate(-90)scale(0.1 -0.1)\">\r\n",
       "      <use xlink:href=\"#DejaVuSans-66\"/>\r\n",
       "      <use x=\"35.205078\" xlink:href=\"#DejaVuSans-28\"/>\r\n",
       "      <use x=\"74.21875\" xlink:href=\"#DejaVuSans-78\"/>\r\n",
       "      <use x=\"133.398438\" xlink:href=\"#DejaVuSans-29\"/>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"line2d_11\">\r\n",
       "    <path clip-path=\"url(#pdca2a1192c)\" d=\"M 62.205398 16.877273 \r\n",
       "L 66.793331 29.317383 \r\n",
       "L 71.237891 40.739372 \r\n",
       "L 75.539078 51.20318 \r\n",
       "L 79.840266 61.086926 \r\n",
       "L 83.99808 70.089833 \r\n",
       "L 88.012522 78.267973 \r\n",
       "L 92.026963 85.940815 \r\n",
       "L 95.898032 92.861076 \r\n",
       "L 99.625727 99.080961 \r\n",
       "L 103.353423 104.865155 \r\n",
       "L 106.937746 110.016003 \r\n",
       "L 110.378696 114.581843 \r\n",
       "L 113.819646 118.776443 \r\n",
       "L 117.117222 122.447909 \r\n",
       "L 120.271427 125.640712 \r\n",
       "L 123.425631 128.521571 \r\n",
       "L 126.436462 130.980483 \r\n",
       "L 129.447293 133.155165 \r\n",
       "L 132.314751 134.962041 \r\n",
       "L 135.182209 136.511111 \r\n",
       "L 138.049667 137.802376 \r\n",
       "L 140.773753 138.790286 \r\n",
       "L 143.497838 139.545526 \r\n",
       "L 146.221923 140.068097 \r\n",
       "L 148.946009 140.357998 \r\n",
       "L 151.670094 140.41523 \r\n",
       "L 154.394179 140.239793 \r\n",
       "L 157.118265 139.831687 \r\n",
       "L 159.84235 139.190911 \r\n",
       "L 162.566435 138.317467 \r\n",
       "L 165.29052 137.211352 \r\n",
       "L 168.014606 135.872569 \r\n",
       "L 170.882064 134.211963 \r\n",
       "L 173.749522 132.293551 \r\n",
       "L 176.760353 130.001757 \r\n",
       "L 179.771184 127.425731 \r\n",
       "L 182.925388 124.422183 \r\n",
       "L 186.079593 121.106691 \r\n",
       "L 189.377169 117.306959 \r\n",
       "L 192.674746 113.166279 \r\n",
       "L 196.115696 108.482065 \r\n",
       "L 199.556646 103.42661 \r\n",
       "L 203.140969 97.765747 \r\n",
       "L 206.868665 91.451138 \r\n",
       "L 210.59636 84.700837 \r\n",
       "L 214.467429 77.229761 \r\n",
       "L 218.48187 68.985702 \r\n",
       "L 222.496312 60.236345 \r\n",
       "L 226.654126 50.641821 \r\n",
       "L 230.955314 40.146057 \r\n",
       "L 235.399874 28.691047 \r\n",
       "L 239.701061 17.015823 \r\n",
       "L 239.701061 17.015823 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"line2d_12\">\r\n",
       "    <path clip-path=\"url(#pdca2a1192c)\" d=\"M 165.315416 137.200171 \r\n",
       "L 133.773376 135.782241 \r\n",
       "L 171.623824 133.740423 \r\n",
       "L 126.203286 130.800205 \r\n",
       "L 180.707932 126.566291 \r\n",
       "L 115.302357 120.469455 \r\n",
       "L 193.789047 111.690011 \r\n",
       "L 99.605019 99.047611 \r\n",
       "L 212.625852 80.842556 \r\n",
       "L 77.000852 54.627276 \r\n",
       "L 239.750852 16.877273 \r\n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:1.5;\"/>\r\n",
       "    <defs>\r\n",
       "     <path d=\"M 0 3 \r\n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \r\n",
       "C 2.683901 1.55874 3 0.795609 3 0 \r\n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \r\n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \r\n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \r\n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \r\n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \r\n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \r\n",
       "z\r\n",
       "\" id=\"md6379b4533\" style=\"stroke:#ff7f0e;\"/>\r\n",
       "    </defs>\r\n",
       "    <g clip-path=\"url(#pdca2a1192c)\">\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"165.315416\" xlink:href=\"#md6379b4533\" y=\"137.200171\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"133.773376\" xlink:href=\"#md6379b4533\" y=\"135.782241\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"171.623824\" xlink:href=\"#md6379b4533\" y=\"133.740423\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"126.203286\" xlink:href=\"#md6379b4533\" y=\"130.800205\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"180.707932\" xlink:href=\"#md6379b4533\" y=\"126.566291\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"115.302357\" xlink:href=\"#md6379b4533\" y=\"120.469455\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"193.789047\" xlink:href=\"#md6379b4533\" y=\"111.690011\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"99.605019\" xlink:href=\"#md6379b4533\" y=\"99.047611\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"212.625852\" xlink:href=\"#md6379b4533\" y=\"80.842556\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"77.000852\" xlink:href=\"#md6379b4533\" y=\"54.627276\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"239.750852\" xlink:href=\"#md6379b4533\" y=\"16.877273\"/>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_3\">\r\n",
       "    <path d=\"M 53.328125 146.6 \r\n",
       "L 53.328125 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_4\">\r\n",
       "    <path d=\"M 248.628125 146.6 \r\n",
       "L 248.628125 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_5\">\r\n",
       "    <path d=\"M 53.328125 146.6 \r\n",
       "L 248.628125 146.6 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_6\">\r\n",
       "    <path d=\"M 53.328125 10.7 \r\n",
       "L 248.628125 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "  </g>\r\n",
       " </g>\r\n",
       " <defs>\r\n",
       "  <clipPath id=\"pdca2a1192c\">\r\n",
       "   <rect height=\"135.9\" width=\"195.3\" x=\"53.328125\" y=\"10.7\"/>\r\n",
       "  </clipPath>\r\n",
       " </defs>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x16b8c6a90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "show_trace(gd(1.1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def train_2d(trainer):  # 本函数将保存在d2lzh_tensorflow2包中方便以后使用\n",
    "    x1, x2, s1, s2 = -5, -2, 0, 0  # s1和s2是自变量状态，本章后续几节会使用\n",
    "    results = [(x1, x2)]\n",
    "    for i in range(20):\n",
    "        x1, x2, s1, s2 = trainer(x1, x2, s1, s2)\n",
    "        results.append((x1, x2))\n",
    "    print('epoch %d, x1 %f, x2 %f' % (i + 1, x1, x2))\n",
    "    return results\n",
    "\n",
    "def show_trace_2d(f, results):  # 本函数将保存在d2lzh_tensorflow2包中方便以后使用\n",
    "    d2l.plt.plot(*zip(*results), '-o', color='#ff7f0e')\n",
    "    x1, x2 = np.meshgrid(np.arange(-5.5, 1.0, 0.1), np.arange(-3.0, 1.0, 0.1))\n",
    "    d2l.plt.contour(x1, x2, f(x1, x2), colors='#1f77b4')\n",
    "    d2l.plt.xlabel('x1')\n",
    "    d2l.plt.ylabel('x2')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 20, x1 -0.057646, x2 -0.000073\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Created with matplotlib (http://matplotlib.org/) -->\r\n",
       "<svg height=\"184pt\" version=\"1.1\" viewBox=\"0 0 248 184\" width=\"248pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       " <defs>\r\n",
       "  <style type=\"text/css\">\r\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\r\n",
       "  </style>\r\n",
       " </defs>\r\n",
       " <g id=\"figure_1\">\r\n",
       "  <g id=\"patch_1\">\r\n",
       "   <path d=\"M 0 184.15625 \r\n",
       "L 248.620313 184.15625 \r\n",
       "L 248.620313 -0 \r\n",
       "L 0 -0 \r\n",
       "z\r\n",
       "\" style=\"fill:none;\"/>\r\n",
       "  </g>\r\n",
       "  <g id=\"axes_1\">\r\n",
       "   <g id=\"patch_2\">\r\n",
       "    <path d=\"M 42.620312 146.6 \r\n",
       "L 237.920313 146.6 \r\n",
       "L 237.920313 10.7 \r\n",
       "L 42.620312 10.7 \r\n",
       "z\r\n",
       "\" style=\"fill:#ffffff;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"matplotlib.axis_1\">\r\n",
       "    <g id=\"xtick_1\">\r\n",
       "     <g id=\"line2d_1\">\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 0 0 \r\n",
       "L 0 3.5 \r\n",
       "\" id=\"m70b9971fb2\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n",
       "      </defs>\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"88.39375\" xlink:href=\"#m70b9971fb2\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_1\">\r\n",
       "      <!-- −4 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 10.59375 35.5 \r\n",
       "L 73.1875 35.5 \r\n",
       "L 73.1875 27.203125 \r\n",
       "L 10.59375 27.203125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-2212\"/>\r\n",
       "       <path d=\"M 37.796875 64.3125 \r\n",
       "L 12.890625 25.390625 \r\n",
       "L 37.796875 25.390625 \r\n",
       "z\r\n",
       "M 35.203125 72.90625 \r\n",
       "L 47.609375 72.90625 \r\n",
       "L 47.609375 25.390625 \r\n",
       "L 58.015625 25.390625 \r\n",
       "L 58.015625 17.1875 \r\n",
       "L 47.609375 17.1875 \r\n",
       "L 47.609375 0 \r\n",
       "L 37.796875 0 \r\n",
       "L 37.796875 17.1875 \r\n",
       "L 4.890625 17.1875 \r\n",
       "L 4.890625 26.703125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-34\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(81.022656 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-34\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_2\">\r\n",
       "     <g id=\"line2d_2\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"149.425\" xlink:href=\"#m70b9971fb2\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_2\">\r\n",
       "      <!-- −2 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 19.1875 8.296875 \r\n",
       "L 53.609375 8.296875 \r\n",
       "L 53.609375 0 \r\n",
       "L 7.328125 0 \r\n",
       "L 7.328125 8.296875 \r\n",
       "Q 12.9375 14.109375 22.625 23.890625 \r\n",
       "Q 32.328125 33.6875 34.8125 36.53125 \r\n",
       "Q 39.546875 41.84375 41.421875 45.53125 \r\n",
       "Q 43.3125 49.21875 43.3125 52.78125 \r\n",
       "Q 43.3125 58.59375 39.234375 62.25 \r\n",
       "Q 35.15625 65.921875 28.609375 65.921875 \r\n",
       "Q 23.96875 65.921875 18.8125 64.3125 \r\n",
       "Q 13.671875 62.703125 7.8125 59.421875 \r\n",
       "L 7.8125 69.390625 \r\n",
       "Q 13.765625 71.78125 18.9375 73 \r\n",
       "Q 24.125 74.21875 28.421875 74.21875 \r\n",
       "Q 39.75 74.21875 46.484375 68.546875 \r\n",
       "Q 53.21875 62.890625 53.21875 53.421875 \r\n",
       "Q 53.21875 48.921875 51.53125 44.890625 \r\n",
       "Q 49.859375 40.875 45.40625 35.40625 \r\n",
       "Q 44.1875 33.984375 37.640625 27.21875 \r\n",
       "Q 31.109375 20.453125 19.1875 8.296875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-32\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(142.053906 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_3\">\r\n",
       "     <g id=\"line2d_3\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"210.45625\" xlink:href=\"#m70b9971fb2\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_3\">\r\n",
       "      <!-- 0 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 31.78125 66.40625 \r\n",
       "Q 24.171875 66.40625 20.328125 58.90625 \r\n",
       "Q 16.5 51.421875 16.5 36.375 \r\n",
       "Q 16.5 21.390625 20.328125 13.890625 \r\n",
       "Q 24.171875 6.390625 31.78125 6.390625 \r\n",
       "Q 39.453125 6.390625 43.28125 13.890625 \r\n",
       "Q 47.125 21.390625 47.125 36.375 \r\n",
       "Q 47.125 51.421875 43.28125 58.90625 \r\n",
       "Q 39.453125 66.40625 31.78125 66.40625 \r\n",
       "z\r\n",
       "M 31.78125 74.21875 \r\n",
       "Q 44.046875 74.21875 50.515625 64.515625 \r\n",
       "Q 56.984375 54.828125 56.984375 36.375 \r\n",
       "Q 56.984375 17.96875 50.515625 8.265625 \r\n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \r\n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \r\n",
       "Q 6.59375 17.96875 6.59375 36.375 \r\n",
       "Q 6.59375 54.828125 13.0625 64.515625 \r\n",
       "Q 19.53125 74.21875 31.78125 74.21875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-30\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(207.275 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"text_4\">\r\n",
       "     <!-- x1 -->\r\n",
       "     <defs>\r\n",
       "      <path d=\"M 54.890625 54.6875 \r\n",
       "L 35.109375 28.078125 \r\n",
       "L 55.90625 0 \r\n",
       "L 45.3125 0 \r\n",
       "L 29.390625 21.484375 \r\n",
       "L 13.484375 0 \r\n",
       "L 2.875 0 \r\n",
       "L 24.125 28.609375 \r\n",
       "L 4.6875 54.6875 \r\n",
       "L 15.28125 54.6875 \r\n",
       "L 29.78125 35.203125 \r\n",
       "L 44.28125 54.6875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-78\"/>\r\n",
       "      <path d=\"M 12.40625 8.296875 \r\n",
       "L 28.515625 8.296875 \r\n",
       "L 28.515625 63.921875 \r\n",
       "L 10.984375 60.40625 \r\n",
       "L 10.984375 69.390625 \r\n",
       "L 28.421875 72.90625 \r\n",
       "L 38.28125 72.90625 \r\n",
       "L 38.28125 8.296875 \r\n",
       "L 54.390625 8.296875 \r\n",
       "L 54.390625 0 \r\n",
       "L 12.40625 0 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-31\"/>\r\n",
       "     </defs>\r\n",
       "     <g transform=\"translate(134.129687 174.876562)scale(0.1 -0.1)\">\r\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\r\n",
       "      <use x=\"59.179688\" xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"matplotlib.axis_2\">\r\n",
       "    <g id=\"ytick_1\">\r\n",
       "     <g id=\"line2d_4\">\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 0 0 \r\n",
       "L -3.5 0 \r\n",
       "\" id=\"mb99e842001\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n",
       "      </defs>\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"42.620312\" xlink:href=\"#mb99e842001\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_5\">\r\n",
       "      <!-- −3 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 40.578125 39.3125 \r\n",
       "Q 47.65625 37.796875 51.625 33 \r\n",
       "Q 55.609375 28.21875 55.609375 21.1875 \r\n",
       "Q 55.609375 10.40625 48.1875 4.484375 \r\n",
       "Q 40.765625 -1.421875 27.09375 -1.421875 \r\n",
       "Q 22.515625 -1.421875 17.65625 -0.515625 \r\n",
       "Q 12.796875 0.390625 7.625 2.203125 \r\n",
       "L 7.625 11.71875 \r\n",
       "Q 11.71875 9.328125 16.59375 8.109375 \r\n",
       "Q 21.484375 6.890625 26.8125 6.890625 \r\n",
       "Q 36.078125 6.890625 40.9375 10.546875 \r\n",
       "Q 45.796875 14.203125 45.796875 21.1875 \r\n",
       "Q 45.796875 27.640625 41.28125 31.265625 \r\n",
       "Q 36.765625 34.90625 28.71875 34.90625 \r\n",
       "L 20.21875 34.90625 \r\n",
       "L 20.21875 43.015625 \r\n",
       "L 29.109375 43.015625 \r\n",
       "Q 36.375 43.015625 40.234375 45.921875 \r\n",
       "Q 44.09375 48.828125 44.09375 54.296875 \r\n",
       "Q 44.09375 59.90625 40.109375 62.90625 \r\n",
       "Q 36.140625 65.921875 28.71875 65.921875 \r\n",
       "Q 24.65625 65.921875 20.015625 65.03125 \r\n",
       "Q 15.375 64.15625 9.8125 62.3125 \r\n",
       "L 9.8125 71.09375 \r\n",
       "Q 15.4375 72.65625 20.34375 73.4375 \r\n",
       "Q 25.25 74.21875 29.59375 74.21875 \r\n",
       "Q 40.828125 74.21875 47.359375 69.109375 \r\n",
       "Q 53.90625 64.015625 53.90625 55.328125 \r\n",
       "Q 53.90625 49.265625 50.4375 45.09375 \r\n",
       "Q 46.96875 40.921875 40.578125 39.3125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-33\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(20.878125 150.399219)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-33\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_2\">\r\n",
       "     <g id=\"line2d_5\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"42.620312\" xlink:href=\"#mb99e842001\" y=\"111.753846\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_6\">\r\n",
       "      <!-- −2 -->\r\n",
       "      <g transform=\"translate(20.878125 115.553065)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_3\">\r\n",
       "     <g id=\"line2d_6\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"42.620312\" xlink:href=\"#mb99e842001\" y=\"76.907692\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_7\">\r\n",
       "      <!-- −1 -->\r\n",
       "      <g transform=\"translate(20.878125 80.706911)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_4\">\r\n",
       "     <g id=\"line2d_7\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"42.620312\" xlink:href=\"#mb99e842001\" y=\"42.061538\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_8\">\r\n",
       "      <!-- 0 -->\r\n",
       "      <g transform=\"translate(29.257812 45.860757)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"text_9\">\r\n",
       "     <!-- x2 -->\r\n",
       "     <g transform=\"translate(14.798437 84.790625)rotate(-90)scale(0.1 -0.1)\">\r\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\r\n",
       "      <use x=\"59.179688\" xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_1\">\r\n",
       "    <path clip-path=\"url(#pda8d74158a)\" d=\"M 237.920313 108.127963 \r\n",
       "L 237.381801 108.269231 \r\n",
       "L 234.86875 108.894675 \r\n",
       "L 231.817188 109.564793 \r\n",
       "L 228.765625 110.145562 \r\n",
       "L 225.714063 110.636982 \r\n",
       "L 222.6625 111.039053 \r\n",
       "L 219.610938 111.351775 \r\n",
       "L 216.559375 111.575148 \r\n",
       "L 213.507813 111.709172 \r\n",
       "L 210.45625 111.753846 \r\n",
       "L 210.45625 111.753846 \r\n",
       "L 210.45625 111.753846 \r\n",
       "L 207.404688 111.709172 \r\n",
       "L 204.353125 111.575148 \r\n",
       "L 201.301563 111.351775 \r\n",
       "L 198.25 111.039053 \r\n",
       "L 195.198438 110.636982 \r\n",
       "L 192.146875 110.145562 \r\n",
       "L 189.095313 109.564793 \r\n",
       "L 186.04375 108.894675 \r\n",
       "L 183.530699 108.269231 \r\n",
       "L 182.992188 108.127963 \r\n",
       "L 179.940625 107.233264 \r\n",
       "L 176.889063 106.244387 \r\n",
       "L 173.8375 105.161331 \r\n",
       "L 172.861 104.784615 \r\n",
       "L 170.785938 103.938352 \r\n",
       "L 167.734375 102.594286 \r\n",
       "L 164.998491 101.3 \r\n",
       "L 164.682813 101.141608 \r\n",
       "L 161.63125 99.504895 \r\n",
       "L 158.672159 97.815385 \r\n",
       "L 158.579688 97.759181 \r\n",
       "L 155.528125 95.79206 \r\n",
       "L 153.383784 94.330769 \r\n",
       "L 152.476563 93.669894 \r\n",
       "L 149.425 91.32679 \r\n",
       "L 148.829573 90.846154 \r\n",
       "L 146.373438 88.716667 \r\n",
       "L 144.88314 87.361538 \r\n",
       "L 143.321875 85.828308 \r\n",
       "L 141.423125 83.876923 \r\n",
       "L 140.270313 82.58913 \r\n",
       "L 138.387434 80.392308 \r\n",
       "L 137.21875 78.898901 \r\n",
       "L 135.724107 76.907692 \r\n",
       "L 134.167188 74.615182 \r\n",
       "L 133.389338 73.423077 \r\n",
       "L 131.354963 69.938462 \r\n",
       "L 131.115625 69.473846 \r\n",
       "L 129.618632 66.453846 \r\n",
       "L 128.121639 62.969231 \r\n",
       "L 128.064063 62.810839 \r\n",
       "L 126.89892 59.484615 \r\n",
       "L 125.900227 56 \r\n",
       "L 125.123466 52.515385 \r\n",
       "L 125.0125 51.818462 \r\n",
       "L 124.584211 49.030769 \r\n",
       "L 124.262993 45.546154 \r\n",
       "L 124.155921 42.061538 \r\n",
       "L 124.262993 38.576923 \r\n",
       "L 124.584211 35.092308 \r\n",
       "L 125.0125 32.304615 \r\n",
       "L 125.123466 31.607692 \r\n",
       "L 125.900227 28.123077 \r\n",
       "L 126.89892 24.638462 \r\n",
       "L 128.064063 21.312238 \r\n",
       "L 128.121639 21.153846 \r\n",
       "L 129.618632 17.669231 \r\n",
       "L 131.115625 14.649231 \r\n",
       "L 131.354963 14.184615 \r\n",
       "L 133.389338 10.7 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_2\">\r\n",
       "    <path clip-path=\"url(#pda8d74158a)\" d=\"M 237.920313 138.078531 \r\n",
       "L 234.86875 138.617063 \r\n",
       "L 231.817188 139.092238 \r\n",
       "L 228.765625 139.504056 \r\n",
       "L 227.655966 139.630769 \r\n",
       "L 225.714063 139.844737 \r\n",
       "L 222.6625 140.119838 \r\n",
       "L 219.610938 140.333806 \r\n",
       "L 216.559375 140.48664 \r\n",
       "L 213.507813 140.57834 \r\n",
       "L 210.45625 140.608907 \r\n",
       "L 207.404688 140.57834 \r\n",
       "L 204.353125 140.48664 \r\n",
       "L 201.301563 140.333806 \r\n",
       "L 198.25 140.119838 \r\n",
       "L 195.198438 139.844737 \r\n",
       "L 193.256534 139.630769 \r\n",
       "L 192.146875 139.504056 \r\n",
       "L 189.095313 139.092238 \r\n",
       "L 186.04375 138.617063 \r\n",
       "L 182.992188 138.078531 \r\n",
       "L 179.940625 137.476643 \r\n",
       "L 176.889063 136.811399 \r\n",
       "L 174.102853 136.146154 \r\n",
       "L 173.8375 136.080406 \r\n",
       "L 170.785938 135.258563 \r\n",
       "L 167.734375 134.370972 \r\n",
       "L 164.682813 133.417634 \r\n",
       "L 162.41875 132.661538 \r\n",
       "L 161.63125 132.388235 \r\n",
       "L 158.579688 131.26086 \r\n",
       "L 155.528125 130.065158 \r\n",
       "L 153.383784 129.176923 \r\n",
       "L 152.476563 128.785793 \r\n",
       "L 149.425 127.399058 \r\n",
       "L 146.373438 125.941209 \r\n",
       "L 145.876672 125.692308 \r\n",
       "L 143.321875 124.357774 \r\n",
       "L 140.270313 122.689607 \r\n",
       "L 139.426263 122.207692 \r\n",
       "L 137.21875 120.891282 \r\n",
       "L 134.167188 118.994103 \r\n",
       "L 133.748346 118.723077 \r\n",
       "L 131.115625 116.94025 \r\n",
       "L 128.697406 115.238462 \r\n",
       "L 128.064063 114.771013 \r\n",
       "L 125.0125 112.433771 \r\n",
       "L 124.155921 111.753846 \r\n",
       "L 121.960938 109.922189 \r\n",
       "L 120.047246 108.269231 \r\n",
       "L 118.909375 107.233264 \r\n",
       "L 116.308043 104.784615 \r\n",
       "L 115.857813 104.336593 \r\n",
       "L 112.903125 101.3 \r\n",
       "L 112.80625 101.194406 \r\n",
       "L 109.801635 97.815385 \r\n",
       "L 109.754688 97.759181 \r\n",
       "L 106.976399 94.330769 \r\n",
       "L 106.703125 93.970292 \r\n",
       "L 104.403397 90.846154 \r\n",
       "L 103.651563 89.749145 \r\n",
       "L 102.061312 87.361538 \r\n",
       "L 100.6 84.992 \r\n",
       "L 99.931164 83.876923 \r\n",
       "L 98.008262 80.392308 \r\n",
       "L 97.548438 79.47967 \r\n",
       "L 96.287125 76.907692 \r\n",
       "L 94.741 73.423077 \r\n",
       "L 94.496875 72.808145 \r\n",
       "L 93.387216 69.938462 \r\n",
       "L 92.198295 66.453846 \r\n",
       "L 91.445313 63.907396 \r\n",
       "L 91.174921 62.969231 \r\n",
       "L 90.325119 59.484615 \r\n",
       "L 89.629826 56 \r\n",
       "L 89.089043 52.515385 \r\n",
       "L 88.702769 49.030769 \r\n",
       "L 88.471005 45.546154 \r\n",
       "L 88.39375 42.061538 \r\n",
       "L 88.471005 38.576923 \r\n",
       "L 88.702769 35.092308 \r\n",
       "L 89.089043 31.607692 \r\n",
       "L 89.629826 28.123077 \r\n",
       "L 90.325119 24.638462 \r\n",
       "L 91.174921 21.153846 \r\n",
       "L 91.445313 20.21568 \r\n",
       "L 92.198295 17.669231 \r\n",
       "L 93.387216 14.184615 \r\n",
       "L 94.496875 11.314932 \r\n",
       "L 94.741 10.7 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_3\">\r\n",
       "    <path clip-path=\"url(#pda8d74158a)\" d=\"M 135.724107 146.6 \r\n",
       "L 134.167188 145.861734 \r\n",
       "L 131.115625 144.355671 \r\n",
       "L 128.697406 143.115385 \r\n",
       "L 128.064063 142.77915 \r\n",
       "L 125.0125 141.097976 \r\n",
       "L 122.442763 139.630769 \r\n",
       "L 121.960938 139.345664 \r\n",
       "L 118.909375 137.476643 \r\n",
       "L 116.808299 136.146154 \r\n",
       "L 115.857813 135.521553 \r\n",
       "L 112.80625 133.450508 \r\n",
       "L 111.679519 132.661538 \r\n",
       "L 109.754688 131.26086 \r\n",
       "L 106.976399 129.176923 \r\n",
       "L 106.703125 128.963579 \r\n",
       "L 103.651563 126.510126 \r\n",
       "L 102.663028 125.692308 \r\n",
       "L 100.6 123.91293 \r\n",
       "L 98.677098 122.207692 \r\n",
       "L 97.548438 121.162308 \r\n",
       "L 94.985125 118.723077 \r\n",
       "L 94.496875 118.236852 \r\n",
       "L 91.564205 115.238462 \r\n",
       "L 91.445313 115.110976 \r\n",
       "L 88.39375 111.753846 \r\n",
       "L 88.39375 111.753846 \r\n",
       "L 85.455208 108.269231 \r\n",
       "L 85.342188 108.127963 \r\n",
       "L 82.731815 104.784615 \r\n",
       "L 82.290625 104.187253 \r\n",
       "L 80.208382 101.3 \r\n",
       "L 79.239063 99.874476 \r\n",
       "L 77.871121 97.815385 \r\n",
       "L 76.1875 95.117618 \r\n",
       "L 75.707479 94.330769 \r\n",
       "L 73.71882 90.846154 \r\n",
       "L 73.135938 89.749145 \r\n",
       "L 71.895192 87.361538 \r\n",
       "L 70.21851 83.876923 \r\n",
       "L 70.084375 83.573913 \r\n",
       "L 68.70625 80.392308 \r\n",
       "L 67.328125 76.907692 \r\n",
       "L 67.032813 76.082389 \r\n",
       "L 66.101283 73.423077 \r\n",
       "L 65.009145 69.938462 \r\n",
       "L 64.045493 66.453846 \r\n",
       "L 63.98125 66.185799 \r\n",
       "L 63.226224 62.969231 \r\n",
       "L 62.534117 59.484615 \r\n",
       "L 61.967848 56 \r\n",
       "L 61.527416 52.515385 \r\n",
       "L 61.212822 49.030769 \r\n",
       "L 61.024066 45.546154 \r\n",
       "L 60.961147 42.061538 \r\n",
       "L 61.024066 38.576923 \r\n",
       "L 61.212822 35.092308 \r\n",
       "L 61.527416 31.607692 \r\n",
       "L 61.967848 28.123077 \r\n",
       "L 62.534117 24.638462 \r\n",
       "L 63.226224 21.153846 \r\n",
       "L 63.98125 17.937278 \r\n",
       "L 64.045493 17.669231 \r\n",
       "L 65.009145 14.184615 \r\n",
       "L 66.101283 10.7 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_4\">\r\n",
       "    <path clip-path=\"url(#pda8d74158a)\" d=\"M 96.287125 146.6 \r\n",
       "L 94.496875 145.300652 \r\n",
       "L 91.564205 143.115385 \r\n",
       "L 91.445313 143.023684 \r\n",
       "L 88.39375 140.608907 \r\n",
       "L 87.188194 139.630769 \r\n",
       "L 85.342188 138.078531 \r\n",
       "L 83.099473 136.146154 \r\n",
       "L 82.290625 135.422932 \r\n",
       "L 79.274963 132.661538 \r\n",
       "L 79.239063 132.627376 \r\n",
       "L 76.1875 129.655204 \r\n",
       "L 75.707479 129.176923 \r\n",
       "L 73.135938 126.510126 \r\n",
       "L 72.364663 125.692308 \r\n",
       "L 70.084375 123.171522 \r\n",
       "L 69.23125 122.207692 \r\n",
       "L 67.032813 119.61359 \r\n",
       "L 66.294013 118.723077 \r\n",
       "L 63.98125 115.805725 \r\n",
       "L 63.540818 115.238462 \r\n",
       "L 60.961147 111.753846 \r\n",
       "L 60.929688 111.709172 \r\n",
       "L 58.55625 108.269231 \r\n",
       "L 57.878125 107.233264 \r\n",
       "L 56.307024 104.784615 \r\n",
       "L 54.826563 102.345385 \r\n",
       "L 54.204399 101.3 \r\n",
       "L 52.249029 97.815385 \r\n",
       "L 51.775 96.916129 \r\n",
       "L 50.438125 94.330769 \r\n",
       "L 48.7525 90.846154 \r\n",
       "L 48.723438 90.781624 \r\n",
       "L 47.211916 87.361538 \r\n",
       "L 45.785952 83.876923 \r\n",
       "L 45.671875 83.573913 \r\n",
       "L 44.496044 80.392308 \r\n",
       "L 43.320212 76.907692 \r\n",
       "L 42.620313 74.615182 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_5\">\r\n",
       "    <path clip-path=\"url(#pda8d74158a)\" d=\"M 67.328125 146.6 \r\n",
       "L 67.032813 146.334224 \r\n",
       "L 63.98125 143.528814 \r\n",
       "L 63.540818 143.115385 \r\n",
       "L 60.929688 140.57834 \r\n",
       "L 59.974148 139.630769 \r\n",
       "L 57.878125 137.476643 \r\n",
       "L 56.609158 136.146154 \r\n",
       "L 54.826563 134.206604 \r\n",
       "L 53.434102 132.661538 \r\n",
       "L 51.775 130.748416 \r\n",
       "L 50.438125 129.176923 \r\n",
       "L 48.723438 127.079042 \r\n",
       "L 47.611186 125.692308 \r\n",
       "L 45.671875 123.171522 \r\n",
       "L 44.943979 122.207692 \r\n",
       "L 42.620313 118.994103 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_6\">\r\n",
       "    <path clip-path=\"url(#pda8d74158a)\" d=\"M 43.320212 146.6 \r\n",
       "L 42.620313 145.861734 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"line2d_8\">\r\n",
       "    <path clip-path=\"url(#pda8d74158a)\" d=\"M 57.878125 111.753846 \r\n",
       "L 88.39375 83.876923 \r\n",
       "L 112.80625 67.150769 \r\n",
       "L 132.33625 57.115077 \r\n",
       "L 147.96025 51.093662 \r\n",
       "L 160.45945 47.480812 \r\n",
       "L 170.45881 45.313103 \r\n",
       "L 178.458298 44.012477 \r\n",
       "L 184.857888 43.232102 \r\n",
       "L 189.977561 42.763876 \r\n",
       "L 194.073299 42.482941 \r\n",
       "L 197.349889 42.31438 \r\n",
       "L 199.971161 42.213243 \r\n",
       "L 202.068179 42.152561 \r\n",
       "L 203.745793 42.116152 \r\n",
       "L 205.087884 42.094307 \r\n",
       "L 206.161558 42.081199 \r\n",
       "L 207.020496 42.073335 \r\n",
       "L 207.707647 42.068616 \r\n",
       "L 208.257367 42.065785 \r\n",
       "L 208.697144 42.064087 \r\n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:1.5;\"/>\r\n",
       "    <defs>\r\n",
       "     <path d=\"M 0 3 \r\n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \r\n",
       "C 2.683901 1.55874 3 0.795609 3 0 \r\n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \r\n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \r\n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \r\n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \r\n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \r\n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \r\n",
       "z\r\n",
       "\" id=\"mbedef2d6ad\" style=\"stroke:#ff7f0e;\"/>\r\n",
       "    </defs>\r\n",
       "    <g clip-path=\"url(#pda8d74158a)\">\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"57.878125\" xlink:href=\"#mbedef2d6ad\" y=\"111.753846\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"88.39375\" xlink:href=\"#mbedef2d6ad\" y=\"83.876923\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"112.80625\" xlink:href=\"#mbedef2d6ad\" y=\"67.150769\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"132.33625\" xlink:href=\"#mbedef2d6ad\" y=\"57.115077\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"147.96025\" xlink:href=\"#mbedef2d6ad\" y=\"51.093662\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"160.45945\" xlink:href=\"#mbedef2d6ad\" y=\"47.480812\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"170.45881\" xlink:href=\"#mbedef2d6ad\" y=\"45.313103\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"178.458298\" xlink:href=\"#mbedef2d6ad\" y=\"44.012477\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"184.857888\" xlink:href=\"#mbedef2d6ad\" y=\"43.232102\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"189.977561\" xlink:href=\"#mbedef2d6ad\" y=\"42.763876\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"194.073299\" xlink:href=\"#mbedef2d6ad\" y=\"42.482941\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"197.349889\" xlink:href=\"#mbedef2d6ad\" y=\"42.31438\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"199.971161\" xlink:href=\"#mbedef2d6ad\" y=\"42.213243\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"202.068179\" xlink:href=\"#mbedef2d6ad\" y=\"42.152561\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"203.745793\" xlink:href=\"#mbedef2d6ad\" y=\"42.116152\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"205.087884\" xlink:href=\"#mbedef2d6ad\" y=\"42.094307\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"206.161558\" xlink:href=\"#mbedef2d6ad\" y=\"42.081199\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"207.020496\" xlink:href=\"#mbedef2d6ad\" y=\"42.073335\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"207.707647\" xlink:href=\"#mbedef2d6ad\" y=\"42.068616\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"208.257367\" xlink:href=\"#mbedef2d6ad\" y=\"42.065785\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"208.697144\" xlink:href=\"#mbedef2d6ad\" y=\"42.064087\"/>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_3\">\r\n",
       "    <path d=\"M 42.620312 146.6 \r\n",
       "L 42.620312 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_4\">\r\n",
       "    <path d=\"M 237.920313 146.6 \r\n",
       "L 237.920313 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_5\">\r\n",
       "    <path d=\"M 42.620313 146.6 \r\n",
       "L 237.920313 146.6 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_6\">\r\n",
       "    <path d=\"M 42.620313 10.7 \r\n",
       "L 237.920313 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "  </g>\r\n",
       " </g>\r\n",
       " <defs>\r\n",
       "  <clipPath id=\"pda8d74158a\">\r\n",
       "   <rect height=\"135.9\" width=\"195.3\" x=\"42.620312\" y=\"10.7\"/>\r\n",
       "  </clipPath>\r\n",
       " </defs>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x16b9446a0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eta = 0.1\n",
    "\n",
    "def f_2d(x1, x2):  # 目标函数\n",
    "    return x1 ** 2 + 2 * x2 ** 2\n",
    "\n",
    "def gd_2d(x1, x2, s1, s2):\n",
    "    return (x1 - eta * 2 * x1, x2 - eta * 4 * x2, 0, 0)\n",
    "\n",
    "show_trace_2d(f_2d, train_2d(gd_2d))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 20, x1 0.082213, x2 0.137309\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Created with matplotlib (http://matplotlib.org/) -->\r\n",
       "<svg height=\"184pt\" version=\"1.1\" viewBox=\"0 0 248 184\" width=\"248pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       " <defs>\r\n",
       "  <style type=\"text/css\">\r\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\r\n",
       "  </style>\r\n",
       " </defs>\r\n",
       " <g id=\"figure_1\">\r\n",
       "  <g id=\"patch_1\">\r\n",
       "   <path d=\"M 0 184.15625 \r\n",
       "L 248.620313 184.15625 \r\n",
       "L 248.620313 -0 \r\n",
       "L 0 -0 \r\n",
       "z\r\n",
       "\" style=\"fill:none;\"/>\r\n",
       "  </g>\r\n",
       "  <g id=\"axes_1\">\r\n",
       "   <g id=\"patch_2\">\r\n",
       "    <path d=\"M 42.620312 146.6 \r\n",
       "L 237.920313 146.6 \r\n",
       "L 237.920313 10.7 \r\n",
       "L 42.620312 10.7 \r\n",
       "z\r\n",
       "\" style=\"fill:#ffffff;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"matplotlib.axis_1\">\r\n",
       "    <g id=\"xtick_1\">\r\n",
       "     <g id=\"line2d_1\">\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 0 0 \r\n",
       "L 0 3.5 \r\n",
       "\" id=\"m3bf3429396\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n",
       "      </defs>\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"88.39375\" xlink:href=\"#m3bf3429396\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_1\">\r\n",
       "      <!-- −4 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 10.59375 35.5 \r\n",
       "L 73.1875 35.5 \r\n",
       "L 73.1875 27.203125 \r\n",
       "L 10.59375 27.203125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-2212\"/>\r\n",
       "       <path d=\"M 37.796875 64.3125 \r\n",
       "L 12.890625 25.390625 \r\n",
       "L 37.796875 25.390625 \r\n",
       "z\r\n",
       "M 35.203125 72.90625 \r\n",
       "L 47.609375 72.90625 \r\n",
       "L 47.609375 25.390625 \r\n",
       "L 58.015625 25.390625 \r\n",
       "L 58.015625 17.1875 \r\n",
       "L 47.609375 17.1875 \r\n",
       "L 47.609375 0 \r\n",
       "L 37.796875 0 \r\n",
       "L 37.796875 17.1875 \r\n",
       "L 4.890625 17.1875 \r\n",
       "L 4.890625 26.703125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-34\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(81.022656 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-34\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_2\">\r\n",
       "     <g id=\"line2d_2\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"149.425\" xlink:href=\"#m3bf3429396\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_2\">\r\n",
       "      <!-- −2 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 19.1875 8.296875 \r\n",
       "L 53.609375 8.296875 \r\n",
       "L 53.609375 0 \r\n",
       "L 7.328125 0 \r\n",
       "L 7.328125 8.296875 \r\n",
       "Q 12.9375 14.109375 22.625 23.890625 \r\n",
       "Q 32.328125 33.6875 34.8125 36.53125 \r\n",
       "Q 39.546875 41.84375 41.421875 45.53125 \r\n",
       "Q 43.3125 49.21875 43.3125 52.78125 \r\n",
       "Q 43.3125 58.59375 39.234375 62.25 \r\n",
       "Q 35.15625 65.921875 28.609375 65.921875 \r\n",
       "Q 23.96875 65.921875 18.8125 64.3125 \r\n",
       "Q 13.671875 62.703125 7.8125 59.421875 \r\n",
       "L 7.8125 69.390625 \r\n",
       "Q 13.765625 71.78125 18.9375 73 \r\n",
       "Q 24.125 74.21875 28.421875 74.21875 \r\n",
       "Q 39.75 74.21875 46.484375 68.546875 \r\n",
       "Q 53.21875 62.890625 53.21875 53.421875 \r\n",
       "Q 53.21875 48.921875 51.53125 44.890625 \r\n",
       "Q 49.859375 40.875 45.40625 35.40625 \r\n",
       "Q 44.1875 33.984375 37.640625 27.21875 \r\n",
       "Q 31.109375 20.453125 19.1875 8.296875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-32\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(142.053906 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"xtick_3\">\r\n",
       "     <g id=\"line2d_3\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"210.45625\" xlink:href=\"#m3bf3429396\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_3\">\r\n",
       "      <!-- 0 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 31.78125 66.40625 \r\n",
       "Q 24.171875 66.40625 20.328125 58.90625 \r\n",
       "Q 16.5 51.421875 16.5 36.375 \r\n",
       "Q 16.5 21.390625 20.328125 13.890625 \r\n",
       "Q 24.171875 6.390625 31.78125 6.390625 \r\n",
       "Q 39.453125 6.390625 43.28125 13.890625 \r\n",
       "Q 47.125 21.390625 47.125 36.375 \r\n",
       "Q 47.125 51.421875 43.28125 58.90625 \r\n",
       "Q 39.453125 66.40625 31.78125 66.40625 \r\n",
       "z\r\n",
       "M 31.78125 74.21875 \r\n",
       "Q 44.046875 74.21875 50.515625 64.515625 \r\n",
       "Q 56.984375 54.828125 56.984375 36.375 \r\n",
       "Q 56.984375 17.96875 50.515625 8.265625 \r\n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \r\n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \r\n",
       "Q 6.59375 17.96875 6.59375 36.375 \r\n",
       "Q 6.59375 54.828125 13.0625 64.515625 \r\n",
       "Q 19.53125 74.21875 31.78125 74.21875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-30\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(207.275 161.198437)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"text_4\">\r\n",
       "     <!-- x1 -->\r\n",
       "     <defs>\r\n",
       "      <path d=\"M 54.890625 54.6875 \r\n",
       "L 35.109375 28.078125 \r\n",
       "L 55.90625 0 \r\n",
       "L 45.3125 0 \r\n",
       "L 29.390625 21.484375 \r\n",
       "L 13.484375 0 \r\n",
       "L 2.875 0 \r\n",
       "L 24.125 28.609375 \r\n",
       "L 4.6875 54.6875 \r\n",
       "L 15.28125 54.6875 \r\n",
       "L 29.78125 35.203125 \r\n",
       "L 44.28125 54.6875 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-78\"/>\r\n",
       "      <path d=\"M 12.40625 8.296875 \r\n",
       "L 28.515625 8.296875 \r\n",
       "L 28.515625 63.921875 \r\n",
       "L 10.984375 60.40625 \r\n",
       "L 10.984375 69.390625 \r\n",
       "L 28.421875 72.90625 \r\n",
       "L 38.28125 72.90625 \r\n",
       "L 38.28125 8.296875 \r\n",
       "L 54.390625 8.296875 \r\n",
       "L 54.390625 0 \r\n",
       "L 12.40625 0 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-31\"/>\r\n",
       "     </defs>\r\n",
       "     <g transform=\"translate(134.129687 174.876562)scale(0.1 -0.1)\">\r\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\r\n",
       "      <use x=\"59.179688\" xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"matplotlib.axis_2\">\r\n",
       "    <g id=\"ytick_1\">\r\n",
       "     <g id=\"line2d_4\">\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 0 0 \r\n",
       "L -3.5 0 \r\n",
       "\" id=\"m47c64e9ecf\" style=\"stroke:#000000;stroke-width:0.8;\"/>\r\n",
       "      </defs>\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"42.620312\" xlink:href=\"#m47c64e9ecf\" y=\"146.6\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_5\">\r\n",
       "      <!-- −3 -->\r\n",
       "      <defs>\r\n",
       "       <path d=\"M 40.578125 39.3125 \r\n",
       "Q 47.65625 37.796875 51.625 33 \r\n",
       "Q 55.609375 28.21875 55.609375 21.1875 \r\n",
       "Q 55.609375 10.40625 48.1875 4.484375 \r\n",
       "Q 40.765625 -1.421875 27.09375 -1.421875 \r\n",
       "Q 22.515625 -1.421875 17.65625 -0.515625 \r\n",
       "Q 12.796875 0.390625 7.625 2.203125 \r\n",
       "L 7.625 11.71875 \r\n",
       "Q 11.71875 9.328125 16.59375 8.109375 \r\n",
       "Q 21.484375 6.890625 26.8125 6.890625 \r\n",
       "Q 36.078125 6.890625 40.9375 10.546875 \r\n",
       "Q 45.796875 14.203125 45.796875 21.1875 \r\n",
       "Q 45.796875 27.640625 41.28125 31.265625 \r\n",
       "Q 36.765625 34.90625 28.71875 34.90625 \r\n",
       "L 20.21875 34.90625 \r\n",
       "L 20.21875 43.015625 \r\n",
       "L 29.109375 43.015625 \r\n",
       "Q 36.375 43.015625 40.234375 45.921875 \r\n",
       "Q 44.09375 48.828125 44.09375 54.296875 \r\n",
       "Q 44.09375 59.90625 40.109375 62.90625 \r\n",
       "Q 36.140625 65.921875 28.71875 65.921875 \r\n",
       "Q 24.65625 65.921875 20.015625 65.03125 \r\n",
       "Q 15.375 64.15625 9.8125 62.3125 \r\n",
       "L 9.8125 71.09375 \r\n",
       "Q 15.4375 72.65625 20.34375 73.4375 \r\n",
       "Q 25.25 74.21875 29.59375 74.21875 \r\n",
       "Q 40.828125 74.21875 47.359375 69.109375 \r\n",
       "Q 53.90625 64.015625 53.90625 55.328125 \r\n",
       "Q 53.90625 49.265625 50.4375 45.09375 \r\n",
       "Q 46.96875 40.921875 40.578125 39.3125 \r\n",
       "z\r\n",
       "\" id=\"DejaVuSans-33\"/>\r\n",
       "      </defs>\r\n",
       "      <g transform=\"translate(20.878125 150.399219)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-33\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_2\">\r\n",
       "     <g id=\"line2d_5\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"42.620312\" xlink:href=\"#m47c64e9ecf\" y=\"111.753846\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_6\">\r\n",
       "      <!-- −2 -->\r\n",
       "      <g transform=\"translate(20.878125 115.553065)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_3\">\r\n",
       "     <g id=\"line2d_6\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"42.620312\" xlink:href=\"#m47c64e9ecf\" y=\"76.907692\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_7\">\r\n",
       "      <!-- −1 -->\r\n",
       "      <g transform=\"translate(20.878125 80.706911)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\r\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSans-31\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"ytick_4\">\r\n",
       "     <g id=\"line2d_7\">\r\n",
       "      <g>\r\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"42.620312\" xlink:href=\"#m47c64e9ecf\" y=\"42.061538\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "     <g id=\"text_8\">\r\n",
       "      <!-- 0 -->\r\n",
       "      <g transform=\"translate(29.257812 45.860757)scale(0.1 -0.1)\">\r\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\r\n",
       "      </g>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "    <g id=\"text_9\">\r\n",
       "     <!-- x2 -->\r\n",
       "     <g transform=\"translate(14.798437 84.790625)rotate(-90)scale(0.1 -0.1)\">\r\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\r\n",
       "      <use x=\"59.179688\" xlink:href=\"#DejaVuSans-32\"/>\r\n",
       "     </g>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_1\">\r\n",
       "    <path clip-path=\"url(#pe0262664b5)\" d=\"M 237.920313 108.127963 \r\n",
       "L 237.381801 108.269231 \r\n",
       "L 234.86875 108.894675 \r\n",
       "L 231.817188 109.564793 \r\n",
       "L 228.765625 110.145562 \r\n",
       "L 225.714063 110.636982 \r\n",
       "L 222.6625 111.039053 \r\n",
       "L 219.610938 111.351775 \r\n",
       "L 216.559375 111.575148 \r\n",
       "L 213.507813 111.709172 \r\n",
       "L 210.45625 111.753846 \r\n",
       "L 210.45625 111.753846 \r\n",
       "L 210.45625 111.753846 \r\n",
       "L 207.404688 111.709172 \r\n",
       "L 204.353125 111.575148 \r\n",
       "L 201.301563 111.351775 \r\n",
       "L 198.25 111.039053 \r\n",
       "L 195.198438 110.636982 \r\n",
       "L 192.146875 110.145562 \r\n",
       "L 189.095313 109.564793 \r\n",
       "L 186.04375 108.894675 \r\n",
       "L 183.530699 108.269231 \r\n",
       "L 182.992188 108.127963 \r\n",
       "L 179.940625 107.233264 \r\n",
       "L 176.889063 106.244387 \r\n",
       "L 173.8375 105.161331 \r\n",
       "L 172.861 104.784615 \r\n",
       "L 170.785938 103.938352 \r\n",
       "L 167.734375 102.594286 \r\n",
       "L 164.998491 101.3 \r\n",
       "L 164.682813 101.141608 \r\n",
       "L 161.63125 99.504895 \r\n",
       "L 158.672159 97.815385 \r\n",
       "L 158.579688 97.759181 \r\n",
       "L 155.528125 95.79206 \r\n",
       "L 153.383784 94.330769 \r\n",
       "L 152.476563 93.669894 \r\n",
       "L 149.425 91.32679 \r\n",
       "L 148.829573 90.846154 \r\n",
       "L 146.373438 88.716667 \r\n",
       "L 144.88314 87.361538 \r\n",
       "L 143.321875 85.828308 \r\n",
       "L 141.423125 83.876923 \r\n",
       "L 140.270313 82.58913 \r\n",
       "L 138.387434 80.392308 \r\n",
       "L 137.21875 78.898901 \r\n",
       "L 135.724107 76.907692 \r\n",
       "L 134.167188 74.615182 \r\n",
       "L 133.389338 73.423077 \r\n",
       "L 131.354963 69.938462 \r\n",
       "L 131.115625 69.473846 \r\n",
       "L 129.618632 66.453846 \r\n",
       "L 128.121639 62.969231 \r\n",
       "L 128.064063 62.810839 \r\n",
       "L 126.89892 59.484615 \r\n",
       "L 125.900227 56 \r\n",
       "L 125.123466 52.515385 \r\n",
       "L 125.0125 51.818462 \r\n",
       "L 124.584211 49.030769 \r\n",
       "L 124.262993 45.546154 \r\n",
       "L 124.155921 42.061538 \r\n",
       "L 124.262993 38.576923 \r\n",
       "L 124.584211 35.092308 \r\n",
       "L 125.0125 32.304615 \r\n",
       "L 125.123466 31.607692 \r\n",
       "L 125.900227 28.123077 \r\n",
       "L 126.89892 24.638462 \r\n",
       "L 128.064063 21.312238 \r\n",
       "L 128.121639 21.153846 \r\n",
       "L 129.618632 17.669231 \r\n",
       "L 131.115625 14.649231 \r\n",
       "L 131.354963 14.184615 \r\n",
       "L 133.389338 10.7 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_2\">\r\n",
       "    <path clip-path=\"url(#pe0262664b5)\" d=\"M 237.920313 138.078531 \r\n",
       "L 234.86875 138.617063 \r\n",
       "L 231.817188 139.092238 \r\n",
       "L 228.765625 139.504056 \r\n",
       "L 227.655966 139.630769 \r\n",
       "L 225.714063 139.844737 \r\n",
       "L 222.6625 140.119838 \r\n",
       "L 219.610938 140.333806 \r\n",
       "L 216.559375 140.48664 \r\n",
       "L 213.507813 140.57834 \r\n",
       "L 210.45625 140.608907 \r\n",
       "L 207.404688 140.57834 \r\n",
       "L 204.353125 140.48664 \r\n",
       "L 201.301563 140.333806 \r\n",
       "L 198.25 140.119838 \r\n",
       "L 195.198438 139.844737 \r\n",
       "L 193.256534 139.630769 \r\n",
       "L 192.146875 139.504056 \r\n",
       "L 189.095313 139.092238 \r\n",
       "L 186.04375 138.617063 \r\n",
       "L 182.992188 138.078531 \r\n",
       "L 179.940625 137.476643 \r\n",
       "L 176.889063 136.811399 \r\n",
       "L 174.102853 136.146154 \r\n",
       "L 173.8375 136.080406 \r\n",
       "L 170.785938 135.258563 \r\n",
       "L 167.734375 134.370972 \r\n",
       "L 164.682813 133.417634 \r\n",
       "L 162.41875 132.661538 \r\n",
       "L 161.63125 132.388235 \r\n",
       "L 158.579688 131.26086 \r\n",
       "L 155.528125 130.065158 \r\n",
       "L 153.383784 129.176923 \r\n",
       "L 152.476563 128.785793 \r\n",
       "L 149.425 127.399058 \r\n",
       "L 146.373438 125.941209 \r\n",
       "L 145.876672 125.692308 \r\n",
       "L 143.321875 124.357774 \r\n",
       "L 140.270313 122.689607 \r\n",
       "L 139.426263 122.207692 \r\n",
       "L 137.21875 120.891282 \r\n",
       "L 134.167188 118.994103 \r\n",
       "L 133.748346 118.723077 \r\n",
       "L 131.115625 116.94025 \r\n",
       "L 128.697406 115.238462 \r\n",
       "L 128.064063 114.771013 \r\n",
       "L 125.0125 112.433771 \r\n",
       "L 124.155921 111.753846 \r\n",
       "L 121.960938 109.922189 \r\n",
       "L 120.047246 108.269231 \r\n",
       "L 118.909375 107.233264 \r\n",
       "L 116.308043 104.784615 \r\n",
       "L 115.857813 104.336593 \r\n",
       "L 112.903125 101.3 \r\n",
       "L 112.80625 101.194406 \r\n",
       "L 109.801635 97.815385 \r\n",
       "L 109.754688 97.759181 \r\n",
       "L 106.976399 94.330769 \r\n",
       "L 106.703125 93.970292 \r\n",
       "L 104.403397 90.846154 \r\n",
       "L 103.651563 89.749145 \r\n",
       "L 102.061312 87.361538 \r\n",
       "L 100.6 84.992 \r\n",
       "L 99.931164 83.876923 \r\n",
       "L 98.008262 80.392308 \r\n",
       "L 97.548438 79.47967 \r\n",
       "L 96.287125 76.907692 \r\n",
       "L 94.741 73.423077 \r\n",
       "L 94.496875 72.808145 \r\n",
       "L 93.387216 69.938462 \r\n",
       "L 92.198295 66.453846 \r\n",
       "L 91.445313 63.907396 \r\n",
       "L 91.174921 62.969231 \r\n",
       "L 90.325119 59.484615 \r\n",
       "L 89.629826 56 \r\n",
       "L 89.089043 52.515385 \r\n",
       "L 88.702769 49.030769 \r\n",
       "L 88.471005 45.546154 \r\n",
       "L 88.39375 42.061538 \r\n",
       "L 88.471005 38.576923 \r\n",
       "L 88.702769 35.092308 \r\n",
       "L 89.089043 31.607692 \r\n",
       "L 89.629826 28.123077 \r\n",
       "L 90.325119 24.638462 \r\n",
       "L 91.174921 21.153846 \r\n",
       "L 91.445313 20.21568 \r\n",
       "L 92.198295 17.669231 \r\n",
       "L 93.387216 14.184615 \r\n",
       "L 94.496875 11.314932 \r\n",
       "L 94.741 10.7 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_3\">\r\n",
       "    <path clip-path=\"url(#pe0262664b5)\" d=\"M 135.724107 146.6 \r\n",
       "L 134.167188 145.861734 \r\n",
       "L 131.115625 144.355671 \r\n",
       "L 128.697406 143.115385 \r\n",
       "L 128.064063 142.77915 \r\n",
       "L 125.0125 141.097976 \r\n",
       "L 122.442763 139.630769 \r\n",
       "L 121.960938 139.345664 \r\n",
       "L 118.909375 137.476643 \r\n",
       "L 116.808299 136.146154 \r\n",
       "L 115.857813 135.521553 \r\n",
       "L 112.80625 133.450508 \r\n",
       "L 111.679519 132.661538 \r\n",
       "L 109.754688 131.26086 \r\n",
       "L 106.976399 129.176923 \r\n",
       "L 106.703125 128.963579 \r\n",
       "L 103.651563 126.510126 \r\n",
       "L 102.663028 125.692308 \r\n",
       "L 100.6 123.91293 \r\n",
       "L 98.677098 122.207692 \r\n",
       "L 97.548438 121.162308 \r\n",
       "L 94.985125 118.723077 \r\n",
       "L 94.496875 118.236852 \r\n",
       "L 91.564205 115.238462 \r\n",
       "L 91.445313 115.110976 \r\n",
       "L 88.39375 111.753846 \r\n",
       "L 88.39375 111.753846 \r\n",
       "L 85.455208 108.269231 \r\n",
       "L 85.342188 108.127963 \r\n",
       "L 82.731815 104.784615 \r\n",
       "L 82.290625 104.187253 \r\n",
       "L 80.208382 101.3 \r\n",
       "L 79.239063 99.874476 \r\n",
       "L 77.871121 97.815385 \r\n",
       "L 76.1875 95.117618 \r\n",
       "L 75.707479 94.330769 \r\n",
       "L 73.71882 90.846154 \r\n",
       "L 73.135938 89.749145 \r\n",
       "L 71.895192 87.361538 \r\n",
       "L 70.21851 83.876923 \r\n",
       "L 70.084375 83.573913 \r\n",
       "L 68.70625 80.392308 \r\n",
       "L 67.328125 76.907692 \r\n",
       "L 67.032813 76.082389 \r\n",
       "L 66.101283 73.423077 \r\n",
       "L 65.009145 69.938462 \r\n",
       "L 64.045493 66.453846 \r\n",
       "L 63.98125 66.185799 \r\n",
       "L 63.226224 62.969231 \r\n",
       "L 62.534117 59.484615 \r\n",
       "L 61.967848 56 \r\n",
       "L 61.527416 52.515385 \r\n",
       "L 61.212822 49.030769 \r\n",
       "L 61.024066 45.546154 \r\n",
       "L 60.961147 42.061538 \r\n",
       "L 61.024066 38.576923 \r\n",
       "L 61.212822 35.092308 \r\n",
       "L 61.527416 31.607692 \r\n",
       "L 61.967848 28.123077 \r\n",
       "L 62.534117 24.638462 \r\n",
       "L 63.226224 21.153846 \r\n",
       "L 63.98125 17.937278 \r\n",
       "L 64.045493 17.669231 \r\n",
       "L 65.009145 14.184615 \r\n",
       "L 66.101283 10.7 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_4\">\r\n",
       "    <path clip-path=\"url(#pe0262664b5)\" d=\"M 96.287125 146.6 \r\n",
       "L 94.496875 145.300652 \r\n",
       "L 91.564205 143.115385 \r\n",
       "L 91.445313 143.023684 \r\n",
       "L 88.39375 140.608907 \r\n",
       "L 87.188194 139.630769 \r\n",
       "L 85.342188 138.078531 \r\n",
       "L 83.099473 136.146154 \r\n",
       "L 82.290625 135.422932 \r\n",
       "L 79.274963 132.661538 \r\n",
       "L 79.239063 132.627376 \r\n",
       "L 76.1875 129.655204 \r\n",
       "L 75.707479 129.176923 \r\n",
       "L 73.135938 126.510126 \r\n",
       "L 72.364663 125.692308 \r\n",
       "L 70.084375 123.171522 \r\n",
       "L 69.23125 122.207692 \r\n",
       "L 67.032813 119.61359 \r\n",
       "L 66.294013 118.723077 \r\n",
       "L 63.98125 115.805725 \r\n",
       "L 63.540818 115.238462 \r\n",
       "L 60.961147 111.753846 \r\n",
       "L 60.929688 111.709172 \r\n",
       "L 58.55625 108.269231 \r\n",
       "L 57.878125 107.233264 \r\n",
       "L 56.307024 104.784615 \r\n",
       "L 54.826563 102.345385 \r\n",
       "L 54.204399 101.3 \r\n",
       "L 52.249029 97.815385 \r\n",
       "L 51.775 96.916129 \r\n",
       "L 50.438125 94.330769 \r\n",
       "L 48.7525 90.846154 \r\n",
       "L 48.723438 90.781624 \r\n",
       "L 47.211916 87.361538 \r\n",
       "L 45.785952 83.876923 \r\n",
       "L 45.671875 83.573913 \r\n",
       "L 44.496044 80.392308 \r\n",
       "L 43.320212 76.907692 \r\n",
       "L 42.620313 74.615182 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_5\">\r\n",
       "    <path clip-path=\"url(#pe0262664b5)\" d=\"M 67.328125 146.6 \r\n",
       "L 67.032813 146.334224 \r\n",
       "L 63.98125 143.528814 \r\n",
       "L 63.540818 143.115385 \r\n",
       "L 60.929688 140.57834 \r\n",
       "L 59.974148 139.630769 \r\n",
       "L 57.878125 137.476643 \r\n",
       "L 56.609158 136.146154 \r\n",
       "L 54.826563 134.206604 \r\n",
       "L 53.434102 132.661538 \r\n",
       "L 51.775 130.748416 \r\n",
       "L 50.438125 129.176923 \r\n",
       "L 48.723438 127.079042 \r\n",
       "L 47.611186 125.692308 \r\n",
       "L 45.671875 123.171522 \r\n",
       "L 44.943979 122.207692 \r\n",
       "L 42.620313 118.994103 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"LineCollection_6\">\r\n",
       "    <path clip-path=\"url(#pe0262664b5)\" d=\"M 43.320212 146.6 \r\n",
       "L 42.620313 145.861734 \r\n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-width:1.5;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"line2d_8\">\r\n",
       "    <path clip-path=\"url(#pe0262664b5)\" d=\"M 57.878125 111.753846 \r\n",
       "L 85.322446 86.08697 \r\n",
       "L 112.572682 61.965723 \r\n",
       "L 127.282863 54.474176 \r\n",
       "L 150.030558 51.252081 \r\n",
       "L 155.671148 49.470746 \r\n",
       "L 164.464534 47.39789 \r\n",
       "L 172.861632 44.736002 \r\n",
       "L 183.083379 37.711461 \r\n",
       "L 192.410402 41.051321 \r\n",
       "L 198.094711 44.269714 \r\n",
       "L 204.383152 44.724847 \r\n",
       "L 208.473359 40.940286 \r\n",
       "L 208.075141 51.802041 \r\n",
       "L 213.512338 44.857695 \r\n",
       "L 208.910558 45.17376 \r\n",
       "L 212.817967 43.299986 \r\n",
       "L 211.291003 43.578407 \r\n",
       "L 212.821934 40.45188 \r\n",
       "L 213.057623 37.888074 \r\n",
       "L 212.965033 37.276863 \r\n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:1.5;\"/>\r\n",
       "    <defs>\r\n",
       "     <path d=\"M 0 3 \r\n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \r\n",
       "C 2.683901 1.55874 3 0.795609 3 0 \r\n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \r\n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \r\n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \r\n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \r\n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \r\n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \r\n",
       "z\r\n",
       "\" id=\"m729ce2a453\" style=\"stroke:#ff7f0e;\"/>\r\n",
       "    </defs>\r\n",
       "    <g clip-path=\"url(#pe0262664b5)\">\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"57.878125\" xlink:href=\"#m729ce2a453\" y=\"111.753846\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"85.322446\" xlink:href=\"#m729ce2a453\" y=\"86.08697\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"112.572682\" xlink:href=\"#m729ce2a453\" y=\"61.965723\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"127.282863\" xlink:href=\"#m729ce2a453\" y=\"54.474176\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"150.030558\" xlink:href=\"#m729ce2a453\" y=\"51.252081\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"155.671148\" xlink:href=\"#m729ce2a453\" y=\"49.470746\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"164.464534\" xlink:href=\"#m729ce2a453\" y=\"47.39789\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"172.861632\" xlink:href=\"#m729ce2a453\" y=\"44.736002\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"183.083379\" xlink:href=\"#m729ce2a453\" y=\"37.711461\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"192.410402\" xlink:href=\"#m729ce2a453\" y=\"41.051321\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"198.094711\" xlink:href=\"#m729ce2a453\" y=\"44.269714\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"204.383152\" xlink:href=\"#m729ce2a453\" y=\"44.724847\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"208.473359\" xlink:href=\"#m729ce2a453\" y=\"40.940286\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"208.075141\" xlink:href=\"#m729ce2a453\" y=\"51.802041\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"213.512338\" xlink:href=\"#m729ce2a453\" y=\"44.857695\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"208.910558\" xlink:href=\"#m729ce2a453\" y=\"45.17376\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"212.817967\" xlink:href=\"#m729ce2a453\" y=\"43.299986\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"211.291003\" xlink:href=\"#m729ce2a453\" y=\"43.578407\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"212.821934\" xlink:href=\"#m729ce2a453\" y=\"40.45188\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"213.057623\" xlink:href=\"#m729ce2a453\" y=\"37.888074\"/>\r\n",
       "     <use style=\"fill:#ff7f0e;stroke:#ff7f0e;\" x=\"212.965033\" xlink:href=\"#m729ce2a453\" y=\"37.276863\"/>\r\n",
       "    </g>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_3\">\r\n",
       "    <path d=\"M 42.620312 146.6 \r\n",
       "L 42.620312 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_4\">\r\n",
       "    <path d=\"M 237.920313 146.6 \r\n",
       "L 237.920313 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_5\">\r\n",
       "    <path d=\"M 42.620313 146.6 \r\n",
       "L 237.920313 146.6 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "   <g id=\"patch_6\">\r\n",
       "    <path d=\"M 42.620313 10.7 \r\n",
       "L 237.920313 10.7 \r\n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\r\n",
       "   </g>\r\n",
       "  </g>\r\n",
       " </g>\r\n",
       " <defs>\r\n",
       "  <clipPath id=\"pe0262664b5\">\r\n",
       "   <rect height=\"135.9\" width=\"195.3\" x=\"42.620312\" y=\"10.7\"/>\r\n",
       "  </clipPath>\r\n",
       " </defs>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x174a85e48>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def sgd_2d(x1, x2, s1, s2):\n",
    "    return (x1 - eta * (2 * x1 + np.random.normal(0.1)),\n",
    "            x2 - eta * (4 * x2 + np.random.normal(0.1)), 0, 0)\n",
    "\n",
    "show_trace_2d(f_2d, train_2d(sgd_2d))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
